-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added loading HDR equirectangular texture (close #189)
- Loading branch information
1 parent
80160fc
commit 2bfba45
Showing
4 changed files
with
163 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "PBR_PrecomputeCommon.fxh" | ||
|
||
Texture2D<float4> g_EnvironmentMap; | ||
SamplerState g_EnvironmentMap_sampler; | ||
|
||
float2 TransformDirectionToSpherePoint(float3 Direction) | ||
{ | ||
float Theta = acos(Direction.y); | ||
float Phi = atan2(Direction.x, -Direction.z); | ||
return -rcp(PI) * float2(0.5 * Phi, Theta); | ||
} | ||
|
||
float4 main(in float4 Pos : SV_Position, | ||
in float3 WorldPos : WORLD_POS) : SV_Target0 | ||
{ | ||
float3 Direction = normalize(WorldPos); | ||
float2 SamplePoint = TransformDirectionToSpherePoint(Direction); | ||
float4 Color = g_EnvironmentMap.SampleLevel(g_EnvironmentMap_sampler, SamplePoint, 0.0); | ||
return float4(Color.xyz, 1.0); | ||
} |