VertexShaderGen: Clip z using user-defined clipping planes.
This commit is contained in:
parent
159247f4ad
commit
b1ed7e80fb
|
@ -724,6 +724,7 @@ Renderer::Renderer()
|
|||
glClearDepthf(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
|
||||
|
||||
|
|
|
@ -196,6 +196,8 @@ inline void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
|
|||
DefineOutputMember(object, api_type, qualifier, "float3", "WorldPos", -1, "TEXCOORD",
|
||||
texgens + 2);
|
||||
}
|
||||
|
||||
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", -1, "SV_ClipDistance");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -216,6 +218,8 @@ inline void AssignVSOutputMembers(T& object, const char* a, const char* b, u32 t
|
|||
object.Write("\t%s.Normal = %s.Normal;\n", a, b);
|
||||
object.Write("\t%s.WorldPos = %s.WorldPos;\n", a, b);
|
||||
}
|
||||
|
||||
object.Write("\t%s.clipDist = %s.clipDist;\n", a, b);
|
||||
}
|
||||
|
||||
// We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
|
||||
|
|
|
@ -399,6 +399,10 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
|||
out.Write("o.colors_1 = color1;\n");
|
||||
}
|
||||
|
||||
// Since we're adjusting z for the depth range before the perspective divide, we have to do our
|
||||
// own clipping.
|
||||
out.Write("o.clipDist = o.pos.z + o.pos.w;\n");
|
||||
|
||||
// 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.
|
||||
out.Write("o.pos.z = o.pos.w * " I_PIXELCENTERCORRECTION".w + o.pos.z * " I_PIXELCENTERCORRECTION".z;\n");
|
||||
|
@ -457,6 +461,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
|||
out.Write("colors_1 = o.colors_1;\n");
|
||||
}
|
||||
|
||||
out.Write("gl_ClipDistance[0] = o.clipDist;\n");
|
||||
out.Write("gl_Position = o.pos;\n");
|
||||
}
|
||||
else // D3D
|
||||
|
|
Loading…
Reference in New Issue