1
0
Fork 0

[GLES2] Fix binding 3D Transforms to mat4 uniforms

This commit is contained in:
Chris Serino 2021-02-03 17:31:55 -06:00
parent cdb5ac52f5
commit 335498df6d
1 changed files with 43 additions and 21 deletions

View File

@ -827,27 +827,49 @@ void ShaderGLES2::use_material(void *p_material) {
case ShaderLanguage::TYPE_MAT4: { case ShaderLanguage::TYPE_MAT4: {
Transform2D tr = V->get(); if (V->get().get_type() == Variant::TRANSFORM) {
GLfloat matrix[16] = { /* build a 16x16 matrix */ Transform tr = V->get();
tr.elements[0][0], GLfloat matrix[16] = { /* build a 16x16 matrix */
tr.elements[0][1], tr.basis.elements[0][0],
0, tr.basis.elements[1][0],
0, tr.basis.elements[2][0],
tr.elements[1][0], 0,
tr.elements[1][1], tr.basis.elements[0][1],
0, tr.basis.elements[1][1],
0, tr.basis.elements[2][1],
0, 0,
0, tr.basis.elements[0][2],
1, tr.basis.elements[1][2],
0, tr.basis.elements[2][2],
tr.elements[2][0], 0,
tr.elements[2][1], tr.origin.x,
0, tr.origin.y,
1 tr.origin.z,
}; 1
};
glUniformMatrix4fv(location, 1, GL_FALSE, matrix); glUniformMatrix4fv(location, 1, GL_FALSE, matrix);
} else {
Transform2D tr = V->get();
GLfloat matrix[16] = { /* build a 16x16 matrix */
tr.elements[0][0],
tr.elements[0][1],
0,
0,
tr.elements[1][0],
tr.elements[1][1],
0,
0,
0,
0,
1,
0,
tr.elements[2][0],
tr.elements[2][1],
0,
1
};
glUniformMatrix4fv(location, 1, GL_FALSE, matrix);
}
} break; } break;