Adapt standard shader to GL ES 2.0

Some shader calculations are now pre-calculated because some math
functions doesn't exist in glsl 110.
This commit is contained in:
victorfisac
2016-06-10 00:49:51 +02:00
parent cbda329bfd
commit 7b07b68bfd
2 changed files with 30 additions and 17 deletions

View File

@@ -1795,8 +1795,13 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
// NOTE: standard shader specific locations are got at render time to keep Shader struct as simple as possible (with just default shader locations)
if (material.shader.id == standardShader.id)
{
// Transpose and inverse model transformations matrix for fragment normal calculations
Matrix transInvTransform = transform;
MatrixTranspose(&transInvTransform);
MatrixInvert(&transInvTransform);
// Send model transformations matrix to shader
glUniformMatrix4fv(glGetUniformLocation(material.shader.id, "modelMatrix"), 1, false, MatrixToFloat(transform));
glUniformMatrix4fv(glGetUniformLocation(material.shader.id, "modelMatrix"), 1, false, MatrixToFloat(transInvTransform));
// Send view transformation matrix to shader. View matrix 8, 9 and 10 are view direction vector axis values (target - position)
glUniform3f(glGetUniformLocation(material.shader.id, "viewDir"), matView.m8, matView.m9, matView.m10);