visibility buffer shader fixes

This commit is contained in:
Turánszki János
2022-11-19 14:57:11 +01:00
parent bb83989039
commit f5e1d4f462
2 changed files with 4 additions and 4 deletions
@@ -77,9 +77,8 @@ void main(uint2 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex)
if (surface.load(prim, ray.Origin, ray.Direction))
{
float4 tmp = mul(GetCamera().view_projection, float4(surface.P, 1));
tmp.xyz /= tmp.w;
depth = tmp.z;
depth = saturate(depth); // this avoids NAN
tmp.xyz /= max(0.0001, tmp.w); // max: avoid nan
depth = saturate(tmp.z); // saturate: avoid blown up values
bin = surface.material.shaderType;
}
@@ -39,7 +39,8 @@ void main(uint2 DTid : SV_DispatchThreadID)
float2 pos2D = clipspace;
float4 pos2DPrev = mul(GetCamera().previous_view_projection, float4(pre, 1));
pos2DPrev.xy /= pos2DPrev.w;
pos2DPrev.xy /= max(0.0001, pos2DPrev.w); // max: avoid nan
pos2DPrev.xy = clamp(pos2DPrev.xy, -1, 1); // clamp: avoid blown up values
float2 velocity = ((pos2DPrev.xy - GetCamera().temporalaa_jitter_prev) - (pos2D.xy - GetCamera().temporalaa_jitter)) * float2(0.5, -0.5);
output_velocity[pixel] = velocity;