Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sky motion vectors #638

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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