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,6 +233,14 @@ 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"
// Most games use the left-aligned form.
" bool left_aligned = gl_in[0].gl_Position.x == gl_in[2].gl_Position.x;\n"
" if (left_aligned) {\n"
// 0 ------ 1
// | - |
// | // |
// | - |
// 2 ----- [3]
" gl_Position = gl_in[0].gl_Position;\n" " gl_Position = gl_in[0].gl_Position;\n"
" gl_PointSize = gl_in[0].gl_PointSize;\n" " gl_PointSize = gl_in[0].gl_PointSize;\n"
" out_vtx = in_vtx[0];\n" " out_vtx = in_vtx[0];\n"
@ -241,18 +249,40 @@ bool CommandProcessor::SetupGL() {
" gl_PointSize = gl_in[1].gl_PointSize;\n" " gl_PointSize = gl_in[1].gl_PointSize;\n"
" out_vtx = in_vtx[1];\n" " out_vtx = in_vtx[1];\n"
" EmitVertex();\n" " EmitVertex();\n"
" gl_Position = gl_in[0].gl_Position + \n" " gl_Position = gl_in[2].gl_Position;\n"
" (gl_in[2].gl_Position - gl_in[1].gl_Position);\n" " gl_PointSize = gl_in[2].gl_PointSize;\n"
" gl_PointSize = gl_in[2].gl_PointSize + \n" " out_vtx = in_vtx[2];\n"
" (gl_in[1].gl_PointSize - gl_in[0].gl_PointSize);\n" " EmitVertex();\n"
" for (int j = 0; j < 16; ++j) {\n" " gl_Position = \n"
" out_vtx.o[j] = in_vtx[0].o[j] + (in_vtx[2].o[j] - in_vtx[1].o[j]);\n" " (gl_in[1].gl_Position + gl_in[2].gl_Position) - \n"
" }\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" " EmitVertex();\n"
" gl_Position = gl_in[2].gl_Position;\n" " gl_Position = gl_in[2].gl_Position;\n"
" gl_PointSize = gl_in[2].gl_PointSize;\n" " gl_PointSize = gl_in[2].gl_PointSize;\n"
" out_vtx = in_vtx[2];\n" " out_vtx = in_vtx[2];\n"
" EmitVertex();\n" " EmitVertex();\n"
" }\n"
" EndPrimitive();\n" " EndPrimitive();\n"
"}\n"; "}\n";
std::string quad_list_shader = std::string quad_list_shader =