Move worldpos into it's own varying.

Previously it was packed into spare slots in clippos.xy and normal.w,
but it's ugly and more importantly it's causing bugs.

This was discovered during the debugging of a zfreeze branch, which
expected clippos.xy to be xy position coordinates in clipspace (as
the name suggested).

Turns out the stereoscopy shader had also run into this trap, modifying
clippos.x (introducing errors with per-pixel lighting).

This commit has been moved outside of the zfreeze PR for fast merging.
This commit is contained in:
Scott Mansell
2015-01-03 01:44:04 +13:00
parent 9c6795c7b7
commit 1b771deb56
4 changed files with 24 additions and 8 deletions

View File

@ -92,7 +92,10 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
}
out.Write("centroid out float4 clipPos;\n");
if (g_ActiveConfig.bEnablePixelLighting)
out.Write("centroid out float4 Normal;\n");
{
out.Write("centroid out float3 Normal;\n");
out.Write("centroid out float3 WorldPos;\n");
}
out.Write("centroid out float4 colors_0;\n");
out.Write("centroid out float4 colors_1;\n");
}
@ -337,11 +340,12 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
}
// clipPos/w needs to be done in pixel shader, not here
out.Write("o.clipPos = float4(pos.x,pos.y,o.pos.z,o.pos.w);\n");
out.Write("o.clipPos = o.pos;\n");
if (g_ActiveConfig.bEnablePixelLighting)
{
out.Write("o.Normal = float4(_norm0.x,_norm0.y,_norm0.z,pos.z);\n");
out.Write("o.Normal = _norm0;\n");
out.Write("o.WorldPos = pos.xyz;\n");
if (components & VB_HAS_COL0)
out.Write("o.colors_0 = color0;\n");
@ -395,7 +399,10 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write("uv%d.xyz = o.tex%d;\n", i, i);
out.Write("clipPos = o.clipPos;\n");
if (g_ActiveConfig.bEnablePixelLighting)
{
out.Write("Normal = o.Normal;\n");
out.Write("WorldPos = o.WorldPos;\n");
}
out.Write("colors_0 = o.colors_0;\n");
out.Write("colors_1 = o.colors_1;\n");
}