Skip to content

Commit

Permalink
taa dx fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 20, 2023
1 parent 2be39a5 commit c77c326
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion data/pipelines/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ float rand(vec3 seed)
vec2 computeStaticObjectMotionVector(vec3 wpos) {
vec4 p = Global.view_projection_no_jitter * vec4(wpos, 1);
vec4 pos_projected = Global.reprojection * p;
return (pos_projected.xy / pos_projected.w * 0.5 + 0.5 - (p.xy / p.w * 0.5 + 0.5)) * 0.5 + 0.5;
vec2 r = (pos_projected.xy / pos_projected.w * 0.5 + 0.5 - (p.xy / p.w * 0.5 + 0.5));
r = r * 0.5 + 0.5;
return r;
}

vec2 cameraReproject(vec2 uv, float depth) {
Expand Down
6 changes: 4 additions & 2 deletions data/pipelines/taa.shd
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ compute_shader [[
if (any(greaterThanEqual(ij, ivec2(u_size.xy)))) return;

vec2 uv = (vec2(ij) + 0.5) / u_size.xy;
float depth = textureLod(u_depthbuf, uv, 0).x;
vec2 motionvec = textureLod(u_motion_vectors, uv, 0).xy * 2 - 1;

#ifndef _ORIGIN_BOTTOM_LEFT
motionvec.y *= -1;
#endif

vec2 uv_prev = uv + motionvec;

vec4 current = textureLod(u_current, uv /*- Global.pixel_jitter*/, 0);
Expand Down
8 changes: 2 additions & 6 deletions src/renderer/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,13 +1156,9 @@ struct PipelineImpl final : Pipeline
static Matrix computeReprojection(const Viewport& current, const Viewport& prev) {
Matrix translation = Matrix::IDENTITY;
translation.setTranslation(Vec3(current.pos - prev.pos));
if (gpu::isOriginBottomLeft()) {
return prev.getProjectionNoJitter() * prev.getViewRotation() * translation * current.getViewRotation().inverted() * current.getProjectionNoJitter().inverted();
}
return prev.getProjectionNoJitter() * prev.getViewRotation() * translation * current.getViewRotation().inverted() * current.getProjectionNoJitter().inverted();
}

Matrix flip = Matrix::IDENTITY;
flip.columns[1].y = -1;
return flip * prev.getProjectionNoJitter() * prev.getViewRotation() * translation * current.getViewRotation().inverted() * current.getProjectionNoJitter().inverted() * flip;
}

bool render(bool only_2d) override
Expand Down

0 comments on commit c77c326

Please sign in to comment.