diff options
author | wwylele <wwylele@gmail.com> | 2017-08-17 09:56:15 +0200 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2017-08-21 07:03:07 +0200 |
commit | 5a4af616c67a4d7968c71b419795777c3601341b (patch) | |
tree | 0168b7dc463129c3f1794e4fd3ab1e4e11a24c80 /src/video_core/renderer_opengl/gl_shader_gen.cpp | |
parent | gl_rasterizer: add clipping plane z<=0 defined in PICA (diff) | |
download | yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar.gz yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar.bz2 yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar.lz yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar.xz yuzu-5a4af616c67a4d7968c71b419795777c3601341b.tar.zst yuzu-5a4af616c67a4d7968c71b419795777c3601341b.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_gen.cpp')
-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); "gl_FragCoord.y < scissor_y2)) discard;\n"; } - out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; + // After perspective divide, OpenGL transform z_over_w from [-1, 1] to [near, far]. Here we use + // default near = 0 and far = 1, and undo the transformation to get the original z_over_w, then + // do our own transformation according to PICA specification. + out += "float z_over_w = 2.0 * gl_FragCoord.z - 1.0;\n"; out += "float depth = z_over_w * depth_scale + depth_offset;\n"; if (state.depthmap_enable == RasterizerRegs::DepthBuffering::WBuffering) { out += "depth /= gl_FragCoord.w;\n"; @@ -1195,7 +1198,7 @@ void main() { texcoord0_w = vert_texcoord0_w; normquat = vert_normquat; view = vert_view; - gl_Position = vec4(vert_position.x, vert_position.y, -vert_position.z, vert_position.w); + gl_Position = vert_position; gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0 // TODO (wwylele): calculate gl_ClipDistance[1] from user-defined clipping plane } |