Skip to content

Commit

Permalink
Use NV_PGRAPH_ZCLIPMIN as threshold for undoing perspective divide
Browse files Browse the repository at this point in the history
  • Loading branch information
polymetal0 committed Jan 4, 2025
1 parent aa084b9 commit 6f4a9b1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hw/xbox/nv2a/pgraph/glsl/psh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ static MString *psh_convert(struct PixelShader *ps, bool z_perspective)
}

if (z_perspective) {
mstring_append(ps->code, "gl_FragDepth = (1.0/gl_FragCoord.w)/clipRange.y;\n");
mstring_append(ps->code, "gl_FragDepth = 1.0/(gl_FragCoord.w * clipRange.y);\n");
}

for (i = 0; i < ps->num_var_refs; i++) {
Expand Down
2 changes: 1 addition & 1 deletion hw/xbox/nv2a/pgraph/glsl/vsh-prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ void pgraph_gen_vsh_prog_glsl(uint16_t version,
body,

/* Correct for the perspective divide */
" if (oPos.w < 0.0) {\n"
" if (oPos.w < clipRange.z) {\n"
/* undo the perspective divide in the case where the point would be
* clipped so opengl can clip it correctly */
" oPos.xyz *= oPos.w;\n"
Expand Down

0 comments on commit 6f4a9b1

Please sign in to comment.