// MinecraftPT — TAA // Temporal anti-aliasing with jittered accumulation and neighborhood clamping. #include "/Lib/Settings.glsl" #include "/Lib/Utilities.glsl" #include "/Lib/BasicFunctions/TemporalNoise.glsl" uniform sampler2D colortex12; // HDR scene (current) uniform sampler2D colortex13; // previous frame HDR layout(location = 0) out vec4 colorOut; layout(location = 1) out vec4 historyOut; // same result, stored for next frame void main(){ vec2 texelCoord = gl_FragCoord.xy; vec3 current = texelFetch(colortex12, ivec2(texelCoord), 0).rgb; // Motion vector vec2 motion = texelFetch(colortex10, ivec2(texelCoord * 0.5), 0).xy * 2.0; vec2 prevCoord = texelCoord + motion; // Sample previous vec3 history = textureLod(colortex13, prevCoord / screenSize, 0.0).rgb; // Neighborhood clamp vec3 minColor = history; vec3 maxColor = history; for (int i = -1; i <= 1; i++){ for (int j = -1; j <= 1; j++){ vec3 c = textureLod(colortex13, (prevCoord + vec2(i, j)) / screenSize, 0.0).rgb; minColor = min(minColor, c); maxColor = max(maxColor, c); }} history = clamp(history, minColor, maxColor); // Subpixel sharpening float sharpening = TAA_SUBPIXEL_SHARPNING; current = current + (current - history) * sharpening * TAA_AGGRESSION; float blend = TAA_BLENDWEIGHT; vec3 color = mix(current, history, blend); colorOut = vec4(color, 1.0); historyOut = vec4(color, 1.0); }