mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
ADDED: Support model normal matrix location #1691
This commit is contained in:
@ -2055,9 +2055,10 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
|
||||
shader.locs[SHADER_LOC_VERTEX_COLOR] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_COLOR);
|
||||
|
||||
// Get handles to GLSL uniform locations (vertex shader)
|
||||
shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, "mvp");
|
||||
shader.locs[SHADER_LOC_MATRIX_PROJECTION] = rlGetLocationUniform(shader.id, "projection");
|
||||
shader.locs[SHADER_LOC_MATRIX_VIEW] = rlGetLocationUniform(shader.id, "view");
|
||||
shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, "mvp");
|
||||
shader.locs[SHADER_LOC_MATRIX_VIEW] = rlGetLocationUniform(shader.id, "view");
|
||||
shader.locs[SHADER_LOC_MATRIX_PROJECTION] = rlGetLocationUniform(shader.id, "projection");
|
||||
shader.locs[SHADER_LOC_MATRIX_NORMAL] = rlGetLocationUniform(shader.id, "matNormal");
|
||||
|
||||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
shader.locs[SHADER_LOC_COLOR_DIFFUSE] = rlGetLocationUniform(shader.id, "colDiffuse");
|
||||
|
||||
@ -1058,6 +1058,9 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins
|
||||
// transform: function parameter transformation
|
||||
matModelView = MatrixMultiply(transforms[0], MatrixMultiply(rlGetMatrixTransform(), matView));
|
||||
}
|
||||
|
||||
// Upload model normal matrix (if locations available)
|
||||
if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModelView)));
|
||||
//-----------------------------------------------------
|
||||
|
||||
// Bind active texture maps (if available)
|
||||
|
||||
@ -739,9 +739,10 @@ typedef enum {
|
||||
SHADER_LOC_VERTEX_TANGENT,
|
||||
SHADER_LOC_VERTEX_COLOR,
|
||||
SHADER_LOC_MATRIX_MVP,
|
||||
SHADER_LOC_MATRIX_MODEL,
|
||||
SHADER_LOC_MATRIX_VIEW,
|
||||
SHADER_LOC_MATRIX_PROJECTION,
|
||||
SHADER_LOC_MATRIX_MODEL,
|
||||
SHADER_LOC_MATRIX_NORMAL,
|
||||
SHADER_LOC_VECTOR_VIEW,
|
||||
SHADER_LOC_COLOR_DIFFUSE,
|
||||
SHADER_LOC_COLOR_SPECULAR,
|
||||
|
||||
@ -417,6 +417,7 @@ typedef enum {
|
||||
SHADER_LOC_MATRIX_MVP,
|
||||
SHADER_LOC_MATRIX_MODEL,
|
||||
SHADER_LOC_MATRIX_VIEW,
|
||||
SHADER_LOC_MATRIX_NORMAL,
|
||||
SHADER_LOC_MATRIX_PROJECTION,
|
||||
SHADER_LOC_VECTOR_VIEW,
|
||||
SHADER_LOC_COLOR_DIFFUSE,
|
||||
|
||||
Reference in New Issue
Block a user