Fixed the billboard shader to be what I intended from the start.

This commit is contained in:
2023-04-04 22:27:27 -07:00
parent 095a60e5dc
commit 78a5e5b4e8

View File

@ -27,10 +27,13 @@ void SimpleBillboardedShaderProgram::compile() {
"out vec2 o_TextCoord;\n" "out vec2 o_TextCoord;\n"
"void main() {\n" "void main() {\n"
"vec3 camRight = vec3(u_View[0][0], u_View[1][0], u_View[2][0]);\n" "vec3 billboardPos = u_Model[3].xyz;\n"
"vec3 camUp = vec3(u_View[0][1], u_View[1][1], u_View[2][1]);\n" "vec3 viewDirection = normalize(billboardPos - u_View[3].xyz);\n"
"vec3 billboardPos = u_View[3].xyz + aPos.x * camRight + aPos.y * camUp;\n" "vec3 up = normalize(vec3(0, 1, 0));\n"
"gl_Position = u_Proj * u_View * u_Model * vec4(billboardPos, 1.0);\n" "vec3 right = normalize(cross(up, viewDirection));\n"
"up = normalize(cross(viewDirection, right));\n"
"vec3 billboardPosCam = vec3(u_View * vec4(billboardPos, 1.0));\n"
"gl_Position = u_Proj * vec4(billboardPosCam + (right * aPos.x + up * aPos.y), 1.0);\n"
"o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n" "o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n"
"}", "}",