@@ -51,34 +51,19 @@ Shader "Hidden/PostProcessing/TemporalAntialiasing"
5151 return (uv + result.xy * k);
5252 }
5353
54- // Adapted from Playdead's TAA implementation
55- // https://github.com/playdeadgames/temporal
56- float4 ClipToAABB (float4 color, float4 p, float3 minimum, float3 maximum)
54+ float4 ClipToAABB (float4 color, float3 minimum, float3 maximum)
5755 {
58- float4 r = color - p;
56+ // Note: only clips towards aabb center (but fast!)
57+ float3 center = 0.5 * (maximum + minimum);
58+ float3 extents = 0.5 * (maximum - minimum);
5959
60- maximum = maximum - p.xyz;
61- minimum = minimum - p.xyz ;
60+ // This is actually `distance`, however the keyword is reserved
61+ float3 offset = color.rgb - center ;
6262
63- if (r.x > maximum.x + 0.00000001 )
64- r *= (maximum.x / r.x);
65-
66- if (r.y > maximum.y + 0.00000001 )
67- r *= (maximum.y / r.y);
68-
69- if (r.z > maximum.z + 0.00000001 )
70- r *= (maximum.z / r.z);
71-
72- if (r.x < minimum.x - 0.00000001 )
73- r *= (minimum.x / r.x);
74-
75- if (r.y < minimum.y - 0.00000001 )
76- r *= (minimum.y / r.y);
77-
78- if (r.z < minimum.z - 0.00000001 )
79- r *= (minimum.z / r.z);
80-
81- return p + r;
63+ float3 ts = abs (extents / (offset + 0.0001 ));
64+ float t = saturate (Min3 (ts.x, ts.y, ts.z));
65+ color.rgb = center + offset * t;
66+ return color;
8267 }
8368
8469 struct OutputSolver
@@ -124,7 +109,7 @@ Shader "Hidden/PostProcessing/TemporalAntialiasing"
124109 history = FastTonemap (history);
125110
126111 // Clip history samples
127- history = ClipToAABB (history, clamp (color, minimum, maximum), minimum.xyz, maximum.xyz);
112+ history = ClipToAABB (history, minimum.xyz, maximum.xyz);
128113
129114 // Blend method
130115 float weight = clamp (
0 commit comments