Review PBR shaders

Issue was related to vertex tangent attibutes not uploaded to GPU, a quick solution was implemented for new vertex attributes loading for already existing meshes... I don't like it specially but it will work for now.
This commit is contained in:
Ray
2019-04-05 16:43:09 +02:00
parent 0f9fe34c3a
commit c600dd0766
6 changed files with 41 additions and 6 deletions

View File

@@ -456,6 +456,7 @@ void rlDeleteBuffers(unsigned int id); // Unload vertex data (V
void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
void rlUpdateBuffer(int bufferId, void *data, int dataSize); // Update GPU buffer with new data
unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic); // Load a new attributes buffer
//------------------------------------------------------------------------------------
// Functions Declaration - rlgl functionality
@@ -2532,6 +2533,29 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
#endif
}
// Load a new attributes buffer
unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic)
{
unsigned int id = 0;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
int drawHint = GL_STATIC_DRAW;
if (dynamic) drawHint = GL_DYNAMIC_DRAW;
if (vaoSupported) glBindVertexArray(vaoId);
glGenBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
glBufferData(GL_ARRAY_BUFFER, size, buffer, drawHint);
glVertexAttribPointer(shaderLoc, 2, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(shaderLoc);
if (vaoSupported) glBindVertexArray(0);
#endif
return id;
}
// Update vertex data on GPU (upload new data to one buffer)
void rlUpdateMesh(Mesh mesh, int buffer, int numVertex)
{