3 ms·
My attempt at temporal anti-aliasing: 1) Add the editor tab for "Buffer A"; move all code with the getColor modification above to this editor; use the followin
by rzzzt 9y ago
My attempt at temporal anti-aliasing:
1) Add the editor tab for "Buffer A"; move all code with the getColor modification above to this editor; use the following mainImage method:
#define SCALE_FACTOR 1.0
#define BLUR_FACTOR 0.95
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
float sum = floor(fragCoord.x / SCALE_FACTOR) + floor(fragCoord.y / SCALE_FACTOR);
bool evenSum = mod(sum, 2.0) < 0.0001;
bool evenFrame = (iFrame % 2) == 0;
vec2 texCoord = fragCoord.xy / iResolution.xy;
vec3 texColor = texture(iChannel0, texCoord).rgb;
if (evenSum == evenFrame) {
fragColor = vec4(mix(texColor, getColor(fragCoord), BLUR_FACTOR), 1.0);
} else {
fragColor = vec4(texColor * BLUR_FACTOR, 1.0);
}
}
2) The "Image" tab should only render the contents of iChannel0 on the display:
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 texCoord = fragCoord.xy / iResolution.xy;
fragColor = texture(iChannel0, texCoord);
}
3) Assign Buffer A as the input/output for iChannel0.
This should do the ray-casting part at effectively half resolution in an alternating checkerboard pattern, blending the previous contents of the buffer with the current output.
- entropicdrifter 9y agoBrilliant! This was my first time playing around with GLSL and I wasn't sure how to implement the buffer to do the blending.
- entropicdrifter 9y agoSo I decided to try combining the way you did it with what I did before, and I came up with this method, which is effectively equivalent to the 4x AA in the top-level comment: void mainImage( out vec4 fragColor, in vec2 fragCoord ) { bool evenFrame = (iFrame % 2) == 0; float x; float y = 0.25; if(evenFrame) { x = 0.25; } else { x = -0.25; } vec3 c1 = getColor(fragCoord + vec2(x, y)); vec3 c2 = getColor(fragCoord + vec2(-x, -y)); vec2 texCoord = fragCoord.xy / iResolution.xy; vec3 texColor = texture(iChannel0, texCoord).rgb; fragColor = vec4(mix(texColor, (c1+c2), 0.5), 1.0); }