Merge pull request #45695 from themindoverall/fix-gles2-3d-transform-uniform-binding

[3.2] [GLES2] Fix binding 3D Transforms to mat4 uniforms
This commit is contained in:
Rémi Verschelde 2021-02-04 10:33:39 +01:00 committed by GitHub
commit 142a53f7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -827,27 +827,49 @@ void ShaderGLES2::use_material(void *p_material) {
case ShaderLanguage::TYPE_MAT4: {
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);
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],
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;