Fixing rectlist for weird cases.

This commit is contained in:
Ben Vanik 2015-01-01 17:33:58 -08:00
parent 2241795713
commit 009f4c4863
1 changed files with 49 additions and 19 deletions

View File

@ -233,26 +233,56 @@ bool CommandProcessor::SetupGL() {
"layout(triangles) in;\n" "layout(triangles) in;\n"
"layout(triangle_strip, max_vertices = 4) out;\n" "layout(triangle_strip, max_vertices = 4) out;\n"
"void main() {\n" "void main() {\n"
" gl_Position = gl_in[0].gl_Position;\n" // Most games use the left-aligned form.
" gl_PointSize = gl_in[0].gl_PointSize;\n" " bool left_aligned = gl_in[0].gl_Position.x == gl_in[2].gl_Position.x;\n"
" out_vtx = in_vtx[0];\n" " if (left_aligned) {\n"
" EmitVertex();\n" // 0 ------ 1
" gl_Position = gl_in[1].gl_Position;\n" // | - |
" gl_PointSize = gl_in[1].gl_PointSize;\n" // | // |
" out_vtx = in_vtx[1];\n" // | - |
" EmitVertex();\n" // 2 ----- [3]
" gl_Position = gl_in[0].gl_Position + \n" " gl_Position = gl_in[0].gl_Position;\n"
" (gl_in[2].gl_Position - gl_in[1].gl_Position);\n" " gl_PointSize = gl_in[0].gl_PointSize;\n"
" gl_PointSize = gl_in[2].gl_PointSize + \n" " out_vtx = in_vtx[0];\n"
" (gl_in[1].gl_PointSize - gl_in[0].gl_PointSize);\n" " EmitVertex();\n"
" for (int j = 0; j < 16; ++j) {\n" " gl_Position = gl_in[1].gl_Position;\n"
" out_vtx.o[j] = in_vtx[0].o[j] + (in_vtx[2].o[j] - in_vtx[1].o[j]);\n" " gl_PointSize = gl_in[1].gl_PointSize;\n"
" out_vtx = in_vtx[1];\n"
" EmitVertex();\n"
" gl_Position = gl_in[2].gl_Position;\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n"
" EmitVertex();\n"
" gl_Position = \n"
" (gl_in[1].gl_Position + gl_in[2].gl_Position) - \n"
" gl_in[0].gl_Position;\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n"
" EmitVertex();\n"
" } else {\n"
// 0 ------ 1
// | - |
// | \\ |
// | - |
// [3] ----- 2
" gl_Position = gl_in[0].gl_Position;\n"
" gl_PointSize = gl_in[0].gl_PointSize;\n"
" out_vtx = in_vtx[0];\n"
" EmitVertex();\n"
" gl_Position = gl_in[1].gl_Position;\n"
" gl_PointSize = gl_in[1].gl_PointSize;\n"
" out_vtx = in_vtx[1];\n"
" EmitVertex();\n"
" gl_Position = gl_in[0].gl_Position + (gl_in[2].gl_Position - \n"
" gl_in[1].gl_Position);\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n"
" EmitVertex();\n"
" gl_Position = gl_in[2].gl_Position;\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n"
" EmitVertex();\n"
" }\n" " }\n"
" EmitVertex();\n"
" gl_Position = gl_in[2].gl_Position;\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n"
" EmitVertex();\n"
" EndPrimitive();\n" " EndPrimitive();\n"
"}\n"; "}\n";
std::string quad_list_shader = std::string quad_list_shader =