VideoCommon: Add a user-defined far clipping plane.
This commit is contained in:
parent
6e2052fae6
commit
94927f360f
|
@ -734,6 +734,7 @@ Renderer::Renderer()
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
{
|
{
|
||||||
glEnable(GL_CLIP_DISTANCE0);
|
glEnable(GL_CLIP_DISTANCE0);
|
||||||
|
glEnable(GL_CLIP_DISTANCE1);
|
||||||
glEnable(GL_DEPTH_CLAMP);
|
glEnable(GL_DEPTH_CLAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1664,7 +1665,10 @@ void Renderer::ResetAPIState()
|
||||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
|
{
|
||||||
glDisable(GL_CLIP_DISTANCE0);
|
glDisable(GL_CLIP_DISTANCE0);
|
||||||
|
glDisable(GL_CLIP_DISTANCE1);
|
||||||
|
}
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
}
|
}
|
||||||
|
@ -1674,7 +1678,10 @@ void Renderer::RestoreAPIState()
|
||||||
// Gets us back into a more game-like state.
|
// Gets us back into a more game-like state.
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
|
{
|
||||||
glEnable(GL_CLIP_DISTANCE0);
|
glEnable(GL_CLIP_DISTANCE0);
|
||||||
|
glEnable(GL_CLIP_DISTANCE1);
|
||||||
|
}
|
||||||
SetGenerationMode();
|
SetGenerationMode();
|
||||||
BPFunctions::SetScissor();
|
BPFunctions::SetScissor();
|
||||||
SetColorMask();
|
SetColorMask();
|
||||||
|
|
|
@ -313,7 +313,10 @@ static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data
|
||||||
{
|
{
|
||||||
out.Write("\tgl_Position = %s.pos;\n", vertex);
|
out.Write("\tgl_Position = %s.pos;\n", vertex);
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
out.Write("\tgl_ClipDistance[0] = %s.clipDist;\n", vertex);
|
{
|
||||||
|
out.Write("\tgl_ClipDistance[0] = %s.clipDist0;\n", vertex);
|
||||||
|
out.Write("\tgl_ClipDistance[1] = %s.clipDist1;\n", vertex);
|
||||||
|
}
|
||||||
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, uid_data->pixel_lighting);
|
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, uid_data->pixel_lighting);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -197,7 +197,8 @@ inline void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
|
||||||
texgens + 2);
|
texgens + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", -1, "SV_ClipDistance");
|
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 0, "SV_ClipDistance", 0);
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 1, "SV_ClipDistance", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -219,7 +220,8 @@ inline void AssignVSOutputMembers(T& object, const char* a, const char* b, u32 t
|
||||||
object.Write("\t%s.WorldPos = %s.WorldPos;\n", a, b);
|
object.Write("\t%s.WorldPos = %s.WorldPos;\n", a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
object.Write("\t%s.clipDist = %s.clipDist;\n", a, b);
|
object.Write("\t%s.clipDist0 = %s.clipDist0;\n", a, b);
|
||||||
|
object.Write("\t%s.clipDist1 = %s.clipDist1;\n", a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
|
// We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
|
||||||
|
|
|
@ -403,7 +403,8 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
||||||
{
|
{
|
||||||
// Since we're adjusting z for the depth range before the perspective divide, we have to do our
|
// Since we're adjusting z for the depth range before the perspective divide, we have to do our
|
||||||
// own clipping.
|
// own clipping.
|
||||||
out.Write("o.clipDist = o.pos.z + o.pos.w;\n");
|
out.Write("o.clipDist0 = o.pos.z + o.pos.w;\n");
|
||||||
|
out.Write("o.clipDist1 = o.pos.w * -o.pos.z;\n");
|
||||||
|
|
||||||
// We have to handle the depth range in the vertex shader, because some games will use a depth range beyond
|
// We have to handle the depth range in the vertex shader, because some games will use a depth range beyond
|
||||||
// the normal depth range of 0..1.
|
// the normal depth range of 0..1.
|
||||||
|
@ -467,7 +468,10 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
out.Write("gl_ClipDistance[0] = o.clipDist;\n");
|
{
|
||||||
|
out.Write("gl_ClipDistance[0] = o.clipDist0;\n");
|
||||||
|
out.Write("gl_ClipDistance[1] = o.clipDist1;\n");
|
||||||
|
}
|
||||||
out.Write("gl_Position = o.pos;\n");
|
out.Write("gl_Position = o.pos;\n");
|
||||||
}
|
}
|
||||||
else // D3D
|
else // D3D
|
||||||
|
|
Loading…
Reference in New Issue