Working on materials PBR support
This commit is contained in:
parent
d1c1eacfc6
commit
963933dec4
|
|
@ -1034,6 +1034,8 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
||||||
RLAPI Shader GetShaderDefault(void); // Get default shader
|
RLAPI Shader GetShaderDefault(void); // Get default shader
|
||||||
RLAPI Texture2D GetTextureDefault(void); // Get default texture
|
RLAPI Texture2D GetTextureDefault(void); // Get default texture
|
||||||
|
|
||||||
|
RLAPI Texture2D rlGenMapCubemap(Texture2D skyHDR, int size);
|
||||||
|
|
||||||
// Shader configuration functions
|
// Shader configuration functions
|
||||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||||
|
|
|
||||||
28
src/rlgl.c
28
src/rlgl.c
|
|
@ -1736,10 +1736,8 @@ Texture2D rlGenMapCubemap(Texture2D skyHDR, int size)
|
||||||
|
|
||||||
// Set up depth face culling and cubemap seamless
|
// Set up depth face culling and cubemap seamless
|
||||||
// TODO: Review all those functions
|
// TODO: Review all those functions
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||||
glLineWidth(2);
|
|
||||||
|
|
||||||
// Setup framebuffer
|
// Setup framebuffer
|
||||||
unsigned int fbo, rbo;
|
unsigned int fbo, rbo;
|
||||||
|
|
@ -1800,6 +1798,10 @@ Texture2D rlGenMapCubemap(Texture2D skyHDR, int size)
|
||||||
cubemap.width = size;
|
cubemap.width = size;
|
||||||
cubemap.height = size;
|
cubemap.height = size;
|
||||||
|
|
||||||
|
// Reset viewport dimensions to default
|
||||||
|
glViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
||||||
|
//glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
return cubemap;
|
return cubemap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2257,7 +2259,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
|
||||||
if (vaoId > 0)
|
if (vaoId > 0)
|
||||||
{
|
{
|
||||||
mesh->vaoId = vaoId;
|
mesh->vaoId = vaoId;
|
||||||
TraceLog(INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId);
|
TraceLog(INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (%i vertices)", mesh->vaoId, mesh->vertexCount);
|
||||||
}
|
}
|
||||||
else TraceLog(WARNING, "Mesh could not be uploaded to VRAM (GPU)");
|
else TraceLog(WARNING, "Mesh could not be uploaded to VRAM (GPU)");
|
||||||
}
|
}
|
||||||
|
|
@ -2388,7 +2390,11 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
(float)material.maps[TEXMAP_DIFFUSE].color.a/255);
|
(float)material.maps[TEXMAP_DIFFUSE].color.a/255);
|
||||||
|
|
||||||
// TODO: Upload to shader material.colAmbient (if available)
|
// TODO: Upload to shader material.colAmbient (if available)
|
||||||
//if (material.shader.locs[LOC_TEXTURE_COLOR02] != -1) glUniform4f(material.shader.locs[LOC_TEXTURE_COLOR02], (float)material.colAmbient.r/255, (float)material.colAmbient.g/255, (float)material.colAmbient.b/255, (float)material.colAmbient.a/255);
|
//if (material.shader.locs[LOC_TEXTURE_COLOR02] != -1)
|
||||||
|
// glUniform4f(material.shader.locs[LOC_TEXTURE_COLOR02], (float)material.colAmbient.r/255,
|
||||||
|
// (float)material.colAmbient.g/255,
|
||||||
|
// (float)material.colAmbient.b/255,
|
||||||
|
// (float)material.colAmbient.a/255);
|
||||||
|
|
||||||
// Upload to shader material.colSpecular (if available)
|
// Upload to shader material.colSpecular (if available)
|
||||||
if (material.shader.locs[LOC_TEXTURE_COLOR03] != -1)
|
if (material.shader.locs[LOC_TEXTURE_COLOR03] != -1)
|
||||||
|
|
@ -2476,7 +2482,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
glEnableVertexAttribArray(material.shader.locs[LOC_VERTEX_TEXCOORD02]);
|
glEnableVertexAttribArray(material.shader.locs[LOC_VERTEX_TEXCOORD02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]);
|
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.vboId[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int eyesCount = 1;
|
int eyesCount = 1;
|
||||||
|
|
@ -2505,12 +2511,9 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
// Unbind all binded texture maps
|
// Unbind all binded texture maps
|
||||||
for (int i = 0; i < MAX_MATERIAL_TEXTURE_MAPS; i++)
|
for (int i = 0; i < MAX_MATERIAL_TEXTURE_MAPS; i++)
|
||||||
{
|
{
|
||||||
if (material.maps[i].tex.id > 0)
|
glActiveTexture(GL_TEXTURE0 + i); // Set shader active texture
|
||||||
{
|
if ((i == TEXMAP_IRRADIANCE) || (i == TEXMAP_PREFILTER) || (i == TEXMAP_CUBEMAP)) glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||||
glActiveTexture(GL_TEXTURE0 + i); // Set shader active texture
|
else glBindTexture(GL_TEXTURE_2D, 0); // Unbind current active texture
|
||||||
if ((i == TEXMAP_IRRADIANCE) || (i == TEXMAP_PREFILTER) || (i == TEXMAP_CUBEMAP)) glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
|
||||||
else glBindTexture(GL_TEXTURE_2D, 0); // Unbind current active texture
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unind vertex array objects (or VBOs)
|
// Unind vertex array objects (or VBOs)
|
||||||
|
|
@ -3751,6 +3754,7 @@ static void DrawDefaultBuffers()
|
||||||
// Draw lines buffers
|
// Draw lines buffers
|
||||||
if (lines.vCounter > 0)
|
if (lines.vCounter > 0)
|
||||||
{
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, whiteTexture);
|
glBindTexture(GL_TEXTURE_2D, whiteTexture);
|
||||||
|
|
||||||
if (vaoSupported)
|
if (vaoSupported)
|
||||||
|
|
@ -3779,6 +3783,7 @@ static void DrawDefaultBuffers()
|
||||||
// Draw triangles buffers
|
// Draw triangles buffers
|
||||||
if (triangles.vCounter > 0)
|
if (triangles.vCounter > 0)
|
||||||
{
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, whiteTexture);
|
glBindTexture(GL_TEXTURE_2D, whiteTexture);
|
||||||
|
|
||||||
if (vaoSupported)
|
if (vaoSupported)
|
||||||
|
|
@ -3844,6 +3849,7 @@ static void DrawDefaultBuffers()
|
||||||
|
|
||||||
//TraceLog(DEBUG, "Quads to render: %i - Vertex Count: %i", quadsCount, draws[i].vertexCount);
|
//TraceLog(DEBUG, "Quads to render: %i - Vertex Count: %i", quadsCount, draws[i].vertexCount);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, draws[i].textureId);
|
glBindTexture(GL_TEXTURE_2D, draws[i].textureId);
|
||||||
|
|
||||||
// NOTE: The final parameter tells the GPU the offset in bytes from the start of the index buffer to the location of the first index to process
|
// NOTE: The final parameter tells the GPU the offset in bytes from the start of the index buffer to the location of the first index to process
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,7 @@ void rlUnloadMesh(Mesh *mesh); // Unload mesh
|
||||||
|
|
||||||
Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
||||||
|
|
||||||
Texture2D rlGenMapCubemap(Texture2D cubemap, int size);
|
Texture2D rlGenMapCubemap(Texture2D skyHDR, int size);
|
||||||
Texture2D rlGenMapIrradiance(Texture2D cubemap, int size);
|
Texture2D rlGenMapIrradiance(Texture2D cubemap, int size);
|
||||||
Texture2D rlGenMapPrefilter(Texture2D cubemap, int size);
|
Texture2D rlGenMapPrefilter(Texture2D cubemap, int size);
|
||||||
Texture2D rlGenMapBRDF(Texture2D cubemap, int size);
|
Texture2D rlGenMapBRDF(Texture2D cubemap, int size);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user