#TAA Screen-shake

11 messages · Page 1 of 1 (latest)

sharp shale
#

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);
    ...
}
#

if I output the worldPos via

fragColor.rgb = worldPos-inverse(view)[3].xyz;

then i can see the shaking

#

so the problem is not with the reproject function, but with either the getDir() method or some other part of the worldPos variable's calculation

sharp shale
#

unless maybe that worldPos should be shaking idk

#

yeah i think the world pos shaking might be a good thing since the goal is to get the position of the previous frame which does change with each jitter

#

the problem might be that the reprojection result doesnt shake (it does i just wasnt looking close enough)

sharp shale
#

noticed a strange pattern if i visualize the reprojection coords subtracted by the current coords

sharp shale
#

probably shouldnt be able to do that

sharp shale
#

maybe it just isnt accumulating or smth and thats causing the "shaking" look