diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 0dae4b91e..015e69da9 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -1112,7 +1112,10 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 1112 | "gl_FragCoord.y < scissor_y2)) discard;\n"; | 1112 | "gl_FragCoord.y < scissor_y2)) discard;\n"; |
| 1113 | } | 1113 | } |
| 1114 | 1114 | ||
| 1115 | out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; | 1115 | // After perspective divide, OpenGL transform z_over_w from [-1, 1] to [near, far]. Here we use |
| 1116 | // default near = 0 and far = 1, and undo the transformation to get the original z_over_w, then | ||
| 1117 | // do our own transformation according to PICA specification. | ||
| 1118 | out += "float z_over_w = 2.0 * gl_FragCoord.z - 1.0;\n"; | ||
| 1116 | out += "float depth = z_over_w * depth_scale + depth_offset;\n"; | 1119 | out += "float depth = z_over_w * depth_scale + depth_offset;\n"; |
| 1117 | if (state.depthmap_enable == RasterizerRegs::DepthBuffering::WBuffering) { | 1120 | if (state.depthmap_enable == RasterizerRegs::DepthBuffering::WBuffering) { |
| 1118 | out += "depth /= gl_FragCoord.w;\n"; | 1121 | out += "depth /= gl_FragCoord.w;\n"; |
| @@ -1195,7 +1198,7 @@ void main() { | |||
| 1195 | texcoord0_w = vert_texcoord0_w; | 1198 | texcoord0_w = vert_texcoord0_w; |
| 1196 | normquat = vert_normquat; | 1199 | normquat = vert_normquat; |
| 1197 | view = vert_view; | 1200 | view = vert_view; |
| 1198 | gl_Position = vec4(vert_position.x, vert_position.y, -vert_position.z, vert_position.w); | 1201 | gl_Position = vert_position; |
| 1199 | gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0 | 1202 | gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0 |
| 1200 | // TODO (wwylele): calculate gl_ClipDistance[1] from user-defined clipping plane | 1203 | // TODO (wwylele): calculate gl_ClipDistance[1] from user-defined clipping plane |
| 1201 | } | 1204 | } |