Skip to content

Commit

Permalink
fix: sky motion vectors (#638)
Browse files Browse the repository at this point in the history
* fix: sky motion vectors

* style: 🎨 apply clang-format changes

---------

Co-authored-by: doodlum <doodlum@users.noreply.github.com>
  • Loading branch information
doodlum and doodlum authored Oct 13, 2024
1 parent 33d284d commit 721731a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion package/Shaders/Sky.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,15 @@ PS_OUTPUT main(PS_INPUT input)
psout.Color = float4(0, 0, 0, 1.0);
# endif // OCCLUSION

float2 screenMotionVector = GetSSMotionVector(input.WorldPosition, input.PreviousWorldPosition, eyeIndex);
float3 viewPosition = mul(CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz;
float2 screenUV = FrameBuffer::ViewToUV(viewPosition, true, eyeIndex);

float4 positionWS = half4(2 * half2(screenUV.x, -screenUV.y + 1) - 1, 1.0, 1);
positionWS = mul(CameraViewProjInverse[eyeIndex], positionWS);
positionWS.xyz = positionWS.xyz / positionWS.w;
positionWS.w = 1;

float2 screenMotionVector = GetSSMotionVector(positionWS, positionWS, eyeIndex);

psout.MotionVectors = float4(screenMotionVector, 0, psout.Color.w);
psout.Normal = float4(0.5, 0.5, 0, psout.Color.w);
Expand Down

0 comments on commit 721731a

Please sign in to comment.