gl: Fix clip-space -> depth conversion. Fixes remaining depth read issues

- Also set some default values for samplers in a cleaner way using their 'natural' float values
This commit is contained in:
kd-11 2017-06-12 19:18:06 +03:00
parent b50d5107b3
commit 69d3d47901
4 changed files with 18 additions and 6 deletions

View file

@ -523,7 +523,19 @@ namespace rsx
float scale_z = rsx::method_registers.viewport_scale_z();
float offset_z = rsx::method_registers.viewport_offset_z();
if (symmetrical_z) offset_z -= .5;
if (symmetrical_z)
{
//Since our clip_space is symetrical [-1, 1] we map it to linear space using the eqn:
//ln = (clip * 2) - 1 to fully utilize the 0-1 range of the depth buffer
//RSX matrices passed already map to the [0, 1] range but mapping to classic OGL
//Requires that we undo this step
//This can be made unnecessary using the call glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE).
//However, ClipControl only made it to opengl core in ver 4.5 though, so this is a workaround.
offset_z -= 1.f;
scale_z *= 2.f;
}
float one = 1.f;