Moved new shader locations to end of enum to avoid breaking existing examples. Added gpu skinning on drawing of instanced meshes.
This commit is contained in:
parent
8d9ddbe09c
commit
568e736fd9
|
|
@ -773,14 +773,11 @@ typedef enum {
|
||||||
SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal
|
SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal
|
||||||
SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent
|
SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent
|
||||||
SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color
|
SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color
|
||||||
SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: boneIds
|
|
||||||
SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: boneWeights
|
|
||||||
SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection
|
SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection
|
||||||
SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform)
|
SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform)
|
||||||
SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection
|
SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection
|
||||||
SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform)
|
SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform)
|
||||||
SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal
|
SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal
|
||||||
SHADER_LOC_BONE_MATRICES, // Shader location: array of matrices uniform: boneMatrices
|
|
||||||
SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view
|
SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view
|
||||||
SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color
|
SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color
|
||||||
SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color
|
SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color
|
||||||
|
|
@ -795,7 +792,10 @@ typedef enum {
|
||||||
SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap
|
SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap
|
||||||
SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance
|
SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance
|
||||||
SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter
|
SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter
|
||||||
SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf
|
SHADER_LOC_MAP_BRDF, // Shader location: sampler2d texture: brdf
|
||||||
|
SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: boneIds
|
||||||
|
SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: boneWeights
|
||||||
|
SHADER_LOC_BONE_MATRICES // Shader location: array of matrices uniform: boneMatrices
|
||||||
} ShaderLocationIndex;
|
} ShaderLocationIndex;
|
||||||
|
|
||||||
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
|
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
|
||||||
|
|
|
||||||
|
|
@ -1738,6 +1738,13 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
|
||||||
|
|
||||||
// Upload model normal matrix (if locations available)
|
// 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(matModel)));
|
if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel)));
|
||||||
|
|
||||||
|
// Upload Bone Transforms
|
||||||
|
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
|
||||||
|
{
|
||||||
|
rlSetUniformMatrices(material.shader.locs[SHADER_LOC_BONE_MATRICES], mesh.boneMatrices, mesh.boneCount);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
// Bind active texture maps (if available)
|
// Bind active texture maps (if available)
|
||||||
|
|
@ -1815,7 +1822,33 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
|
||||||
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
|
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
|
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
|
||||||
|
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
|
||||||
|
{
|
||||||
|
if (mesh.vboId[6] != 0)
|
||||||
|
{
|
||||||
|
rlEnableVertexBuffer(mesh.vboId[6]);
|
||||||
|
rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_BONEIDS], 4, RL_UNSIGNED_BYTE, 0, 0, 0);
|
||||||
|
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_BONEIDS]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set default value for defined vertex attribute in shader but not provided by mesh
|
||||||
|
// WARNING: It could result in GPU undefined behaviour
|
||||||
|
float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_BONEIDS], value, SHADER_ATTRIB_VEC4, 4);
|
||||||
|
rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_BONEIDS]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (material.shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS] != -1)
|
||||||
|
{
|
||||||
|
rlEnableVertexBuffer(mesh.vboId[7]);
|
||||||
|
rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS], 4, RL_FLOAT, 0, 0, 0);
|
||||||
|
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int eyeCount = 1;
|
int eyeCount = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user