Skip to content

Commit

Permalink
fix: water depth in VR
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlum authored and alandtse committed Mar 4, 2024
1 parent b3fd577 commit bf7992b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions package/Shaders/Water.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,10 @@ PS_OUTPUT main(PS_INPUT input)
DynamicResolutionParams1.xy * (DynamicResolutionParams2.xy * input.HPosition.xy));
float2 depthOffset =
DynamicResolutionParams2.xy * input.HPosition.xy * VPOSOffset.xy + VPOSOffset.zw;
float depthMul = length(float3((depthOffset * 2 - 1) * depth / ProjData.xy, depth));

float3 viewPosition = mul(CameraView[eyeIndex], float4(input.WPosition.xyz, 1)).xyz;
float2 screenUV = ViewToUV(viewPosition, true, eyeIndex);
float depthMul = length(float3((screenUV * 2 - 1) * depth / ProjData.xy, depth));

float3 depthAdjustedViewDirection = -viewDirection * depthMul;
float viewSurfaceAngle = dot(depthAdjustedViewDirection, ReflectPlane[eyeIndex].xyz);

Expand Down

0 comments on commit bf7992b

Please sign in to comment.