[MODELS] Better fix for GPU skinning issues (#4353)
* Make the max VBO match the animation flag. * re-enable GPU skinning for mac, and fix the max buffer to be correct based on the GPU skinning support flag.
This commit is contained in:
parent
d9c10ed264
commit
09987b01cc
3 changed files with 13 additions and 10 deletions
13
src/config.h
13
src/config.h
|
@ -121,12 +121,10 @@
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
|
||||||
|
|
||||||
// The mac OpenGL drivers do not support more than 8 VBOs, so we can't support GPU animations
|
|
||||||
#ifndef __APPLE__
|
|
||||||
#define RL_SUPPORT_MESH_ANIMATION_VBO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#define RL_SUPPORT_MESH_GPU_SKINNING // Remove this if your GPU does not support more than 8 VBOs
|
||||||
|
|
||||||
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
|
||||||
#endif
|
#endif
|
||||||
|
@ -237,7 +235,12 @@
|
||||||
// rmodels: Configuration values
|
// rmodels: Configuration values
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
||||||
|
|
||||||
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh
|
#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh
|
||||||
|
#else
|
||||||
|
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module: raudio - Configuration Flags
|
// Module: raudio - Configuration Flags
|
||||||
|
|
|
@ -4175,7 +4175,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
|
||||||
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
|
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
|
||||||
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
|
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS);
|
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS);
|
||||||
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
|
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2);
|
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
if (mesh->boneIds != NULL)
|
if (mesh->boneIds != NULL)
|
||||||
{
|
{
|
||||||
// Enable vertex attribute: boneIds (shader-location = 6)
|
// Enable vertex attribute: boneIds (shader-location = 6)
|
||||||
|
@ -1492,7 +1492,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
// 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)));
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
// Upload Bone Transforms
|
// Upload Bone Transforms
|
||||||
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
|
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
|
||||||
{
|
{
|
||||||
|
@ -1578,7 +1578,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
|
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
|
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
|
||||||
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
|
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
|
||||||
{
|
{
|
||||||
|
@ -1738,7 +1738,7 @@ 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)));
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
// Upload Bone Transforms
|
// Upload Bone Transforms
|
||||||
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
|
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue