DX11: Preserve w coordinates of lines and points. Fixes glitches when a line is partially behind the camera.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7357 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1ee5e3a0e1
commit
aa19fa97d9
|
@ -55,12 +55,9 @@ static const char LINE_GS_COMMON[] =
|
|||
// Pretend input[0] is on the bottom and input[1] is on top.
|
||||
// We generate vertices to the left and right.
|
||||
|
||||
// Correct w coordinate so screen-space math will work
|
||||
"VS_OUTPUT l0 = input[0];\n"
|
||||
"l0.pos /= l0.pos.w;\n"
|
||||
"VS_OUTPUT r0 = l0;\n"
|
||||
"VS_OUTPUT l1 = input[1];\n"
|
||||
"l1.pos /= l1.pos.w;\n"
|
||||
"VS_OUTPUT r1 = l1;\n"
|
||||
|
||||
// GameCube/Wii's line drawing algorithm is a little quirky. It does not
|
||||
|
@ -81,16 +78,18 @@ static const char LINE_GS_COMMON[] =
|
|||
"offset = float2(0, -Params.LineWidth/528);\n"
|
||||
"}\n"
|
||||
|
||||
"l0.pos.xy -= offset;\n"
|
||||
"r0.pos.xy += offset;\n"
|
||||
"l1.pos.xy -= offset;\n"
|
||||
"r1.pos.xy += offset;\n"
|
||||
"l0.pos.xy -= offset * input[0].pos.w;\n"
|
||||
"r0.pos.xy += offset * input[0].pos.w;\n"
|
||||
"l1.pos.xy -= offset * input[1].pos.w;\n"
|
||||
"r1.pos.xy += offset * input[1].pos.w;\n"
|
||||
|
||||
"#ifndef NUM_TEXCOORDS\n"
|
||||
"#error NUM_TEXCOORDS not defined\n"
|
||||
"#endif\n"
|
||||
|
||||
// Apply TexOffset to all tex coordinates in the vertex
|
||||
// FIXME: The game may be able to enable TexOffset for some coords and
|
||||
// disable for others, but where is that information stored?
|
||||
"#if NUM_TEXCOORDS >= 1\n"
|
||||
"r0.tex0.x += Params.TexOffset;\n"
|
||||
"r1.tex0.x += Params.TexOffset;\n"
|
||||
|
|
|
@ -52,15 +52,14 @@ static const char POINT_GS_COMMON[] =
|
|||
"[maxvertexcount(4)]\n"
|
||||
"void main(point VS_OUTPUT input[1], inout TriangleStream<VS_OUTPUT> outStream)\n"
|
||||
"{\n"
|
||||
// Correct w coordinate so screen-space math will work
|
||||
"VS_OUTPUT ptLL = input[0];\n"
|
||||
"ptLL.pos /= ptLL.pos.w;\n"
|
||||
"VS_OUTPUT ptLR = ptLL;\n"
|
||||
"VS_OUTPUT ptUL = ptLL;\n"
|
||||
"VS_OUTPUT ptUR = ptLL;\n"
|
||||
|
||||
// Distance from center to upper right vertex
|
||||
"float2 offset = float2(Params.PointSize/640, -Params.PointSize/528);\n"
|
||||
// Offset from center to upper right vertex
|
||||
// Lerp Params.PointSize/2 from [0,0..640,528] to [-1,1..1,-1]
|
||||
"float2 offset = float2(Params.PointSize/640, -Params.PointSize/528) * input[0].pos.w;\n"
|
||||
|
||||
"ptLL.pos.xy += float2(-1,-1) * offset;\n"
|
||||
"ptLR.pos.xy += float2(1,-1) * offset;\n"
|
||||
|
@ -74,6 +73,8 @@ static const char POINT_GS_COMMON[] =
|
|||
"#endif\n"
|
||||
|
||||
// Apply TexOffset to all tex coordinates in the vertex
|
||||
// FIXME: The game may be able to enable TexOffset for some coords and
|
||||
// disable for others, but where is that information stored?
|
||||
"#if NUM_TEXCOORDS >= 1\n"
|
||||
"ptLL.tex0.xy += float2(0,1) * texOffset;\n"
|
||||
"ptLR.tex0.xy += texOffset;\n"
|
||||
|
|
Loading…
Reference in New Issue