I have a scene that's mostly displayed via tracing rays on one triangle (the exceptions / things that are not rendered this way are the clouds and hand-held item, which are rasterized normally) and am attempting to add TAA.
The fragment shader for that triangle shifts the position used to make the ray directions with a jitter and all the rays are shot out from the camera position.
The taa shader then uses the previous frames jitter and camera matrix to figure out which of the previous frame's pixels to sample, however when that previous frame's jitter is used in this calculation it makes the entire screen shake (as shown in the video).
vec2 reproject(vec3 worldPos) {
vec4 projectionVec = projection * view * vec4(worldPos, 1.0f);
projectionVec.xyz /= projectionVec.w;
projectionVec.xy = projectionVec.xy * 0.5f + 0.5f;
return projectionVec.xy;
}
vec3 getDir() {
vec2 screenSpace = (gl_FragCoord.xy+vec2(xOffsets[offsetIdxOld], yOffsets[offsetIdxOld])) / res;
vec4 clipSpace = vec4(screenSpace * 2.0f - 1.0f, -1.0f, 1.0f);
vec4 eyeSpace = vec4(vec2(inverse(projection) * clipSpace), -1.0f, 0.0f);
return normalize(vec3(inverse(view)*eyeSpace));
}
const float nearClip = 0.01f;
void main() {
vec3 worldPos = inverse(view)[3].xyz + (getDir()* (nearClip/currentColor.w));
vec2 reprojected = reproject(worldPos);
vec4 oldColor = texture(in_color_old, reprojected);
...
}