aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlbavoil <[email protected]>2016-12-06 09:46:18 +0100
committerlbavoil <[email protected]>2016-12-06 09:46:18 +0100
commit7b7ea79895b71209b87bf5c0a8882608d1f6ba24 (patch)
treea5dd624fa408000f4241de690dcff2e3b9ad30b1 /src
parentMerge pull request #2 from alex-leleka/patch-1 (diff)
downloadhbaoplus-7b7ea79895b71209b87bf5c0a8882608d1f6ba24.tar.xz
hbaoplus-7b7ea79895b71209b87bf5c0a8882608d1f6ba24.zip
Revert previous change in CoarseAO_PS. Add comments in RotateDirection.
Diffstat (limited to 'src')
-rw-r--r--src/shaders/src/CoarseAO_PS.hlsl11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/shaders/src/CoarseAO_PS.hlsl b/src/shaders/src/CoarseAO_PS.hlsl
index 8df2a46..4854acb 100644
--- a/src/shaders/src/CoarseAO_PS.hlsl
+++ b/src/shaders/src/CoarseAO_PS.hlsl
@@ -64,10 +64,13 @@ float3 FetchQuarterResViewPos(float2 UV)
}
//----------------------------------------------------------------------------------
-float2 RotateDirection(float2 Dir, float2 CosSin)
+float2 RotateDirection(float2 Direction, float2 RotationCosSin)
{
- return float2(Dir.x*CosSin.x - Dir.y*CosSin.y,
- Dir.x*CosSin.y + Dir.y*CosSin.x);
+ // Dir is the normalized 2D direction to be rotated
+ // RotationCosSin is (cos(alpha),sin(alpha)) where alpha is the rotation angle
+ // A 2D rotation matrix is applied (see https://en.wikipedia.org/wiki/Rotation_matrix)
+ return float2(Direction.x*RotationCosSin.x - Direction.y*RotationCosSin.y,
+ Direction.x*RotationCosSin.y + Direction.y*RotationCosSin.x);
}
//----------------------------------------------------------------------------------
@@ -152,7 +155,7 @@ float ComputeCoarseAO(float2 FullResUV, float3 ViewPosition, float3 ViewNormal,
float Angle = Alpha * DirectionIndex;
// Compute normalized 2D direction
- float2 Direction = RotateDirection(Rand.xy, float2(cos(Angle), sin(Angle)));
+ float2 Direction = RotateDirection(float2(cos(Angle), sin(Angle)), Rand.xy);
#if API_GL
// To match the reference D3D11 implementation