Skip to content

Commit 1272651

Browse files
JeffM2501psxdev
authored andcommitted
[MODELS] Better fix for GPU skinning issues (raysan5#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.
1 parent d12d963 commit 1272651

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/config.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@
121121
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
122122
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
123123

124-
// The mac OpenGL drivers do not support more than 8 VBOs, so we can't support GPU animations
125-
#ifndef __APPLE__
126-
#define RL_SUPPORT_MESH_ANIMATION_VBO
127-
#endif
128124

129-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
125+
#define RL_SUPPORT_MESH_GPU_SKINNING // Remove this if your GPU does not support more than 8 VBOs
126+
127+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
130128
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
131129
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
132130
#endif
@@ -237,7 +235,12 @@
237235
// rmodels: Configuration values
238236
//------------------------------------------------------------------------------------
239237
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
238+
239+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
240240
#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh
241+
#else
242+
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
243+
#endif
241244

242245
//------------------------------------------------------------------------------------
243246
// Module: raudio - Configuration Flags

src/rlgl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4243,7 +4243,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
42434243
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
42444244
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
42454245

4246-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
4246+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
42474247
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS);
42484248
glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
42494249
#endif

src/rmodels.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
13741374
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2);
13751375
}
13761376

1377-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
1377+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
13781378
if (mesh->boneIds != NULL)
13791379
{
13801380
// Enable vertex attribute: boneIds (shader-location = 6)
@@ -1521,7 +1521,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
15211521
// Upload model normal matrix (if locations available)
15221522
if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel)));
15231523
#endif
1524-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
1524+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
15251525
// Upload Bone Transforms
15261526
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
15271527
{
@@ -1607,7 +1607,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
16071607
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
16081608
}
16091609

1610-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
1610+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
16111611
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
16121612
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
16131613
{
@@ -1773,8 +1773,8 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
17731773
#if !defined(PLATFORM_VITA)
17741774
// Upload model normal matrix (if locations available)
17751775
if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel)));
1776-
#endif
1777-
#ifdef RL_SUPPORT_MESH_ANIMATION_VBO
1776+
#endif
1777+
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
17781778
// Upload Bone Transforms
17791779
if (material.shader.locs[SHADER_LOC_BONE_MATRICES] != -1 && mesh.boneMatrices)
17801780
{

0 commit comments

Comments
 (0)