void taa(inout float3 old, in float2 id, int2 iResolution) { id *= iResolution; id += .5; if (any(id <= 1) || any(id >= iResolution - 1)) return; // get the neighborhood min / max from this frame's render float3 center = lastFrame[id].rgb; float3 minColor = center; float3 maxColor = center; for (int iy = -1; iy <= 1; ++iy) { for (int ix = -1; ix <= 1; ++ix) { if (ix == 0 && iy == 0) continue; float3 color = lastFrame[id + int2(ix, iy)].rgb; minColor = min(minColor, color); maxColor = max(maxColor, color); } } //center = max(minColor, center); //center = min(maxColor, center); // get last frame's pixel and clamp it to the neighborhood of this frame old = lerp(old, center, 0.4); }