[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

View file

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