Browse Source

Working on PBR materials, renamed some data

raysan5 8 years ago
parent
commit
d368403a13
8 changed files with 568 additions and 664 deletions
  1. 1 1
      examples/models/models_cubicmap.c
  2. 10 10
      examples/models/models_material_pbr.c
  3. 3 3
      examples/models/models_skybox.c
  4. 1 1
      src/core.c
  5. 61 66
      src/models.c
  6. 58 52
      src/raylib.h
  7. 390 491
      src/rlgl.c
  8. 44 40
      src/rlgl.h

+ 1 - 1
examples/models/models_cubicmap.c

@@ -31,7 +31,7 @@ int main()
     
     
     // NOTE: By default each cube is mapped to one part of texture atlas
     // NOTE: By default each cube is mapped to one part of texture atlas
     Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");    // Load map texture
     Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");    // Load map texture
-    model.material.maps[TEXMAP_DIFFUSE].tex = texture;                  // Set map diffuse texture
+    model.material.maps[MAP_DIFFUSE].texture = texture;                  // Set map diffuse texture
     
     
     Vector3 mapPosition = { -16.0f, 0.0f, -8.0f };          // Set model position
     Vector3 mapPosition = { -16.0f, 0.0f, -8.0f };          // Set model position
 
 

+ 10 - 10
examples/models/models_material_pbr.c

@@ -58,18 +58,18 @@ int main()
     Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
     Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
     model.material = LoadMaterialPBR(texHDR, (Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
     model.material = LoadMaterialPBR(texHDR, (Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
     
     
-    SetMaterialTexture(&model.material, TEXMAP_ALBEDO, LoadTexture("resources/pbr/trooper_albedo.png"));
-    SetMaterialTexture(&model.material, TEXMAP_NORMAL, LoadTexture("resources/pbr/trooper_normals.png"));
-    SetMaterialTexture(&model.material, TEXMAP_METALNESS, LoadTexture("resources/pbr/trooper_metalness.png"));
-    SetMaterialTexture(&model.material, TEXMAP_ROUGHNESS, LoadTexture("resources/pbr/trooper_roughness.png"));
-    SetMaterialTexture(&model.material, TEXMAP_OCCLUSION, LoadTexture("resources/pbr/trooper_ao.png"));
+    SetMaterialTexture(&model.material, MAP_ALBEDO, LoadTexture("resources/pbr/trooper_albedo.png"));
+    SetMaterialTexture(&model.material, MAP_NORMAL, LoadTexture("resources/pbr/trooper_normals.png"));
+    SetMaterialTexture(&model.material, MAP_METALNESS, LoadTexture("resources/pbr/trooper_metalness.png"));
+    SetMaterialTexture(&model.material, MAP_ROUGHNESS, LoadTexture("resources/pbr/trooper_roughness.png"));
+    SetMaterialTexture(&model.material, MAP_OCCLUSION, LoadTexture("resources/pbr/trooper_ao.png"));
     
     
     // Set textures filtering for better quality
     // Set textures filtering for better quality
-    SetTextureFilter(model.material.maps[TEXMAP_ALBEDO].tex, FILTER_BILINEAR);
-    SetTextureFilter(model.material.maps[TEXMAP_NORMAL].tex, FILTER_BILINEAR);
-    SetTextureFilter(model.material.maps[TEXMAP_METALNESS].tex, FILTER_BILINEAR);
-    SetTextureFilter(model.material.maps[TEXMAP_ROUGHNESS].tex, FILTER_BILINEAR);
-    SetTextureFilter(model.material.maps[TEXMAP_OCCLUSION].tex, FILTER_BILINEAR);
+    SetTextureFilter(model.material.maps[MAP_ALBEDO].texture, FILTER_BILINEAR);
+    SetTextureFilter(model.material.maps[MAP_NORMAL].texture, FILTER_BILINEAR);
+    SetTextureFilter(model.material.maps[MAP_METALNESS].texture, FILTER_BILINEAR);
+    SetTextureFilter(model.material.maps[MAP_ROUGHNESS].texture, FILTER_BILINEAR);
+    SetTextureFilter(model.material.maps[MAP_OCCLUSION].texture, FILTER_BILINEAR);
     
     
     int renderModeLoc = GetShaderLocation(model.material.shader, "renderMode");
     int renderModeLoc = GetShaderLocation(model.material.shader, "renderMode");
     SetShaderValuei(model.material.shader, renderModeLoc, (int[1]){ 0 }, 1);
     SetShaderValuei(model.material.shader, renderModeLoc, (int[1]){ 0 }, 1);

+ 3 - 3
examples/models/models_skybox.c

@@ -30,8 +30,8 @@ int main()
     skybox.material.shader = LoadShader("resources/shaders/skybox.vs", "resources/shaders/skybox.fs");
     skybox.material.shader = LoadShader("resources/shaders/skybox.vs", "resources/shaders/skybox.fs");
 
 
     Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
     Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
-    skybox.material.maps[TEXMAP_CUBEMAP].tex = rlGenMapCubemap(texHDR, 512);
-    SetShaderValuei(skybox.material.shader, GetShaderLocation(skybox.material.shader, "environmentMap"), (int[1]){ TEXMAP_CUBEMAP }, 1);
+    skybox.material.maps[MAP_CUBEMAP].texture = GenTextureCubemap(texHDR, 512);
+    SetShaderValuei(skybox.material.shader, GetShaderLocation(skybox.material.shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, 1);
 
 
     // Get skybox shader locations
     // Get skybox shader locations
     skybox.material.shader.locs[LOC_MATRIX_PROJECTION] = GetShaderLocation(skybox.material.shader, "projection");
     skybox.material.shader.locs[LOC_MATRIX_PROJECTION] = GetShaderLocation(skybox.material.shader, "projection");
@@ -66,7 +66,7 @@ int main()
 
 
             Begin3dMode(camera);
             Begin3dMode(camera);
 
 
-                DrawModel(skybox, VectorZero(), 1.0f, RED);
+                DrawModel(skybox, VectorZero(), 1.0f, WHITE);
                 
                 
                 DrawGrid(10, 1.0f);
                 DrawGrid(10, 1.0f);
 
 

+ 1 - 1
src/core.c

@@ -1878,7 +1878,7 @@ static void InitGraphicsDevice(int width, int height)
 #if defined(PLATFORM_DESKTOP)
 #if defined(PLATFORM_DESKTOP)
     // Load OpenGL 3.3 extensions
     // Load OpenGL 3.3 extensions
     // NOTE: GLFW loader function is passed as parameter
     // NOTE: GLFW loader function is passed as parameter
-    rlglLoadExtensions(glfwGetProcAddress);
+    rlLoadExtensions(glfwGetProcAddress);
 #endif
 #endif
 
 
     // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
     // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)

+ 61 - 66
src/models.c

@@ -1281,12 +1281,12 @@ Material LoadMaterialDefault(void)
     Material material = { 0 };
     Material material = { 0 };
 
 
     material.shader = GetShaderDefault();
     material.shader = GetShaderDefault();
-    material.maps[TEXMAP_DIFFUSE].tex = GetTextureDefault();   // White texture (1x1 pixel)
-    //material.maps[TEXMAP_NORMAL].tex;           // NOTE: By default, not set
-    //material.maps[TEXMAP_SPECULAR].tex;         // NOTE: By default, not set
+    material.maps[MAP_DIFFUSE].texture = GetTextureDefault();   // White texture (1x1 pixel)
+    //material.maps[MAP_NORMAL].tex;           // NOTE: By default, not set
+    //material.maps[MAP_SPECULAR].tex;         // NOTE: By default, not set
 
 
-    material.maps[TEXMAP_DIFFUSE].color = WHITE;    // Diffuse color
-    material.maps[TEXMAP_SPECULAR].color = WHITE;   // Specular color
+    material.maps[MAP_DIFFUSE].color = WHITE;    // Diffuse color
+    material.maps[MAP_SPECULAR].color = WHITE;   // Specular color
 
 
     return material;
     return material;
 }
 }
@@ -1294,7 +1294,7 @@ Material LoadMaterialDefault(void)
 // Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
 // Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
 Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float roughness)
 Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float roughness)
 {
 {
-    Material mat = { 0 };
+    Material mat = { 0 };       // NOTE: All maps textures are set to { 0 }
     
     
     #define     PATH_PBR_VS     "resources/shaders/pbr.vs"              // Path to physically based rendering vertex shader
     #define     PATH_PBR_VS     "resources/shaders/pbr.vs"              // Path to physically based rendering vertex shader
     #define     PATH_PBR_FS     "resources/shaders/pbr.fs"              // Path to physically based rendering fragment shader
     #define     PATH_PBR_FS     "resources/shaders/pbr.fs"              // Path to physically based rendering fragment shader
@@ -1303,16 +1303,16 @@ Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float rou
     
     
     // Get required locations points for PBR material
     // Get required locations points for PBR material
     // NOTE: Those location names must be available and used in the shader code
     // NOTE: Those location names must be available and used in the shader code
-    mat.shader.locs[LOC_TEXMAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
-    mat.shader.locs[LOC_TEXMAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
-    mat.shader.locs[LOC_TEXMAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
-    mat.shader.locs[LOC_TEXMAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
-    mat.shader.locs[LOC_TEXMAP_OCCUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
-    mat.shader.locs[LOC_TEXMAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
-    mat.shader.locs[LOC_TEXMAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
-    mat.shader.locs[LOC_TEXMAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
-    mat.shader.locs[LOC_TEXMAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
-    mat.shader.locs[LOC_TEXMAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
+    mat.shader.locs[LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
+    mat.shader.locs[LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
+    mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
+    mat.shader.locs[LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
+    mat.shader.locs[LOC_MAP_OCCUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
+    mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
+    mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
+    mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
+    mat.shader.locs[LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
+    mat.shader.locs[LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
 
 
     // Set view matrix location
     // Set view matrix location
     mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "mMatrix");
     mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "mMatrix");
@@ -1320,30 +1320,25 @@ Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float rou
     mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
     mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
 
 
     // Set up material properties color
     // Set up material properties color
-    mat.maps[TEXMAP_ALBEDO].color = albedo;
-    mat.maps[TEXMAP_NORMAL].color = (Color){ 128, 128, 255, 255 };
-    mat.maps[TEXMAP_METALNESS].value = metalness;
-    mat.maps[TEXMAP_ROUGHNESS].value = roughness;
-    mat.maps[TEXMAP_OCCLUSION].value = 1.0f;
-    mat.maps[TEXMAP_EMISSION].value = 0.0f;
-    mat.maps[TEXMAP_HEIGHT].value = 0.0f;
+    mat.maps[MAP_ALBEDO].color = albedo;
+    mat.maps[MAP_NORMAL].color = (Color){ 128, 128, 255, 255 };
+    mat.maps[MAP_METALNESS].value = metalness;
+    mat.maps[MAP_ROUGHNESS].value = roughness;
+    mat.maps[MAP_OCCLUSION].value = 1.0f;
+    mat.maps[MAP_EMISSION].value = 0.0f;
+    mat.maps[MAP_HEIGHT].value = 0.0f;
     
     
-    #define CUBEMAP_SIZE        1024        // Cubemap texture size
+    #define CUBEMAP_SIZE         512        // Cubemap texture size
     #define IRRADIANCE_SIZE       32        // Irradiance map from cubemap texture size
     #define IRRADIANCE_SIZE       32        // Irradiance map from cubemap texture size
     #define PREFILTERED_SIZE     256        // Prefiltered HDR environment map texture size
     #define PREFILTERED_SIZE     256        // Prefiltered HDR environment map texture size
     #define BRDF_SIZE            512        // BRDF LUT texture map size
     #define BRDF_SIZE            512        // BRDF LUT texture map size
 
 
     // Set up environment materials cubemap
     // Set up environment materials cubemap
-    Texture2D cubemap = rlGenMapCubemap(hdr, CUBEMAP_SIZE);
-    mat.maps[TEXMAP_IRRADIANCE].tex = rlGenMapIrradiance(cubemap, IRRADIANCE_SIZE);
-    mat.maps[TEXMAP_PREFILTER].tex = rlGenMapPrefilter(cubemap, PREFILTERED_SIZE);
-    mat.maps[TEXMAP_BRDF].tex = rlGenMapBRDF(cubemap, BRDF_SIZE);
+    Texture2D cubemap = GenTextureCubemap(hdr, CUBEMAP_SIZE);
+    mat.maps[MAP_IRRADIANCE].texture = GenTextureIrradiance(cubemap, IRRADIANCE_SIZE);
+    mat.maps[MAP_PREFILTER].texture = GenTexturePrefilter(cubemap, PREFILTERED_SIZE);
+    mat.maps[MAP_BRDF].texture = GenTextureBRDF(cubemap, BRDF_SIZE);
     UnloadTexture(cubemap);
     UnloadTexture(cubemap);
-    
-    // NOTE: All maps textures are set to { 0 }
-    
-    // Reset viewport dimensions to default
-    rlViewport(0, 0, GetScreenWidth(), GetScreenHeight());
 
 
     return mat;
     return mat;
 }
 }
@@ -1355,53 +1350,53 @@ void UnloadMaterial(Material material)
     UnloadShader(material.shader);
     UnloadShader(material.shader);
 
 
     // Unload loaded texture maps
     // Unload loaded texture maps
-    for (int i = 0; i < MAX_MATERIAL_TEXTURE_MAPS; i++)
+    for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
     {
     {
         // NOTE: We already check for (tex.id > 0) inside function
         // NOTE: We already check for (tex.id > 0) inside function
-        rlDeleteTextures(material.maps[i].tex.id); 
+        rlDeleteTextures(material.maps[i].texture.id); 
     }
     }
 }
 }
 
 
 // Set material texture
 // Set material texture
 void SetMaterialTexture(Material *mat, int texmapType, Texture2D texture)
 void SetMaterialTexture(Material *mat, int texmapType, Texture2D texture)
 {
 {
-    mat->maps[texmapType].tex = texture;
+    mat->maps[texmapType].texture = texture;
 
 
     // Update MaterialProperty use sampler state to use texture fetch instead of color attribute
     // Update MaterialProperty use sampler state to use texture fetch instead of color attribute
     int location = -1;
     int location = -1;
     switch (texmapType)
     switch (texmapType)
     {
     {
-        case TEXMAP_ALBEDO:
+        case MAP_ALBEDO:
         {
         {
             location = GetShaderLocation(mat->shader, "albedo.useSampler");
             location = GetShaderLocation(mat->shader, "albedo.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_NORMAL:
+        case MAP_NORMAL:
         {
         {
             location = GetShaderLocation(mat->shader, "normals.useSampler");
             location = GetShaderLocation(mat->shader, "normals.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_METALNESS:
+        case MAP_METALNESS:
         {
         {
             location = GetShaderLocation(mat->shader, "metalness.useSampler");
             location = GetShaderLocation(mat->shader, "metalness.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_ROUGHNESS:
+        case MAP_ROUGHNESS:
         {
         {
             location = GetShaderLocation(mat->shader, "roughness.useSampler");
             location = GetShaderLocation(mat->shader, "roughness.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_OCCLUSION:
+        case MAP_OCCLUSION:
         {
         {
             location = GetShaderLocation(mat->shader, "occlusion.useSampler");
             location = GetShaderLocation(mat->shader, "occlusion.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_EMISSION:
+        case MAP_EMISSION:
         {
         {
             location = GetShaderLocation(mat->shader, "emission.useSampler");
             location = GetShaderLocation(mat->shader, "emission.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
         } break;
         } break;
-        case TEXMAP_HEIGHT:
+        case MAP_HEIGHT:
         {
         {
             location = GetShaderLocation(mat->shader, "height.useSampler");
             location = GetShaderLocation(mat->shader, "height.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 1 }, 1);
@@ -1412,44 +1407,44 @@ void SetMaterialTexture(Material *mat, int texmapType, Texture2D texture)
 // Unset texture from material and unload it from GPU
 // Unset texture from material and unload it from GPU
 void UnsetMaterialTexture(Material *mat, int texmapType)
 void UnsetMaterialTexture(Material *mat, int texmapType)
 {
 {
-    UnloadTexture(mat->maps[texmapType].tex);
-    mat->maps[texmapType].tex = (Texture2D){ 0 };
+    UnloadTexture(mat->maps[texmapType].texture);
+    mat->maps[texmapType].texture = (Texture2D){ 0 };
 
 
     // Update MaterialProperty use sampler state to use texture fetch instead of color attribute
     // Update MaterialProperty use sampler state to use texture fetch instead of color attribute
     int location = -1;
     int location = -1;
     switch (texmapType)
     switch (texmapType)
     {
     {
-        case TEXMAP_ALBEDO:
+        case MAP_ALBEDO:
         {
         {
             location = GetShaderLocation(mat->shader, "albedo.useSampler");
             location = GetShaderLocation(mat->shader, "albedo.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_NORMAL:
+        case MAP_NORMAL:
         {
         {
             location = GetShaderLocation(mat->shader, "normals.useSampler");
             location = GetShaderLocation(mat->shader, "normals.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_METALNESS:
+        case MAP_METALNESS:
         {
         {
             location = GetShaderLocation(mat->shader, "metalness.useSampler");
             location = GetShaderLocation(mat->shader, "metalness.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_ROUGHNESS:
+        case MAP_ROUGHNESS:
         {
         {
             location = GetShaderLocation(mat->shader, "roughness.useSampler");
             location = GetShaderLocation(mat->shader, "roughness.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_OCCLUSION:
+        case MAP_OCCLUSION:
         {
         {
             location = GetShaderLocation(mat->shader, "occlusion.useSampler");
             location = GetShaderLocation(mat->shader, "occlusion.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_EMISSION:
+        case MAP_EMISSION:
         {
         {
             location = GetShaderLocation(mat->shader, "emission.useSampler");
             location = GetShaderLocation(mat->shader, "emission.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
         } break;
         } break;
-        case TEXMAP_HEIGHT:
+        case MAP_HEIGHT:
         {
         {
             location = GetShaderLocation(mat->shader, "height.useSampler");
             location = GetShaderLocation(mat->shader, "height.useSampler");
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
             SetShaderValuei(mat->shader, location, (int [1]){ 0 }, 1);
@@ -1481,7 +1476,7 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
     //Matrix matModel = MatrixMultiply(model.transform, matTransform);    // Transform to world-space coordinates
     //Matrix matModel = MatrixMultiply(model.transform, matTransform);    // Transform to world-space coordinates
 
 
     model.transform = MatrixMultiply(model.transform, matTransform);
     model.transform = MatrixMultiply(model.transform, matTransform);
-    model.material.maps[TEXMAP_DIFFUSE].color = tint;       // TODO: Multiply tint color by diffuse color?
+    model.material.maps[MAP_DIFFUSE].color = tint;       // TODO: Multiply tint color by diffuse color?
 
 
     rlDrawMesh(model.mesh, model.material, model.transform);
     rlDrawMesh(model.mesh, model.material, model.transform);
 }
 }
@@ -2244,16 +2239,16 @@ static Material LoadMTL(const char *fileName)
                     case 'd':   // Kd float float float     Diffuse color (RGB)
                     case 'd':   // Kd float float float     Diffuse color (RGB)
                     {
                     {
                         sscanf(buffer, "Kd %f %f %f", &color.x, &color.y, &color.z);
                         sscanf(buffer, "Kd %f %f %f", &color.x, &color.y, &color.z);
-                        material.maps[TEXMAP_DIFFUSE].color.r = (unsigned char)(color.x*255);
-                        material.maps[TEXMAP_DIFFUSE].color.g = (unsigned char)(color.y*255);
-                        material.maps[TEXMAP_DIFFUSE].color.b = (unsigned char)(color.z*255);
+                        material.maps[MAP_DIFFUSE].color.r = (unsigned char)(color.x*255);
+                        material.maps[MAP_DIFFUSE].color.g = (unsigned char)(color.y*255);
+                        material.maps[MAP_DIFFUSE].color.b = (unsigned char)(color.z*255);
                     } break;
                     } break;
                     case 's':   // Ks float float float     Specular color (RGB)
                     case 's':   // Ks float float float     Specular color (RGB)
                     {
                     {
                         sscanf(buffer, "Ks %f %f %f", &color.x, &color.y, &color.z);
                         sscanf(buffer, "Ks %f %f %f", &color.x, &color.y, &color.z);
-                        material.maps[TEXMAP_SPECULAR].color.r = (unsigned char)(color.x*255);
-                        material.maps[TEXMAP_SPECULAR].color.g = (unsigned char)(color.y*255);
-                        material.maps[TEXMAP_SPECULAR].color.b = (unsigned char)(color.z*255);
+                        material.maps[MAP_SPECULAR].color.r = (unsigned char)(color.x*255);
+                        material.maps[MAP_SPECULAR].color.g = (unsigned char)(color.y*255);
+                        material.maps[MAP_SPECULAR].color.b = (unsigned char)(color.z*255);
                     } break;
                     } break;
                     case 'e':   // Ke float float float     Emmisive color (RGB)
                     case 'e':   // Ke float float float     Emmisive color (RGB)
                     {
                     {
@@ -2285,12 +2280,12 @@ static Material LoadMTL(const char *fileName)
                         if (buffer[5] == 'd')       // map_Kd string    Diffuse color texture map.
                         if (buffer[5] == 'd')       // map_Kd string    Diffuse color texture map.
                         {
                         {
                             result = sscanf(buffer, "map_Kd %s", mapFileName);
                             result = sscanf(buffer, "map_Kd %s", mapFileName);
-                            if (result != EOF) material.maps[TEXMAP_DIFFUSE].tex = LoadTexture(mapFileName);
+                            if (result != EOF) material.maps[MAP_DIFFUSE].texture = LoadTexture(mapFileName);
                         }
                         }
                         else if (buffer[5] == 's')  // map_Ks string    Specular color texture map.
                         else if (buffer[5] == 's')  // map_Ks string    Specular color texture map.
                         {
                         {
                             result = sscanf(buffer, "map_Ks %s", mapFileName);
                             result = sscanf(buffer, "map_Ks %s", mapFileName);
-                            if (result != EOF) material.maps[TEXMAP_SPECULAR].tex = LoadTexture(mapFileName);
+                            if (result != EOF) material.maps[MAP_SPECULAR].texture = LoadTexture(mapFileName);
                         }
                         }
                         else if (buffer[5] == 'a')  // map_Ka string    Ambient color texture map.
                         else if (buffer[5] == 'a')  // map_Ka string    Ambient color texture map.
                         {
                         {
@@ -2300,12 +2295,12 @@ static Material LoadMTL(const char *fileName)
                     case 'B':       // map_Bump string      Bump texture map.
                     case 'B':       // map_Bump string      Bump texture map.
                     {
                     {
                         result = sscanf(buffer, "map_Bump %s", mapFileName);
                         result = sscanf(buffer, "map_Bump %s", mapFileName);
-                        if (result != EOF) material.maps[TEXMAP_NORMAL].tex = LoadTexture(mapFileName);
+                        if (result != EOF) material.maps[MAP_NORMAL].texture = LoadTexture(mapFileName);
                     } break;
                     } break;
                     case 'b':       // map_bump string      Bump texture map.
                     case 'b':       // map_bump string      Bump texture map.
                     {
                     {
                         result = sscanf(buffer, "map_bump %s", mapFileName);
                         result = sscanf(buffer, "map_bump %s", mapFileName);
-                        if (result != EOF) material.maps[TEXMAP_NORMAL].tex = LoadTexture(mapFileName);
+                        if (result != EOF) material.maps[MAP_NORMAL].texture = LoadTexture(mapFileName);
                     } break;
                     } break;
                     case 'd':       // map_d string         Opacity texture map.
                     case 'd':       // map_d string         Opacity texture map.
                     {
                     {
@@ -2320,7 +2315,7 @@ static Material LoadMTL(const char *fileName)
                 {
                 {
                     float alpha = 1.0f;
                     float alpha = 1.0f;
                     sscanf(buffer, "d %f", &alpha);
                     sscanf(buffer, "d %f", &alpha);
-                    material.maps[TEXMAP_DIFFUSE].color.a = (unsigned char)(alpha*255);
+                    material.maps[MAP_DIFFUSE].color.a = (unsigned char)(alpha*255);
                 }
                 }
                 else if (buffer[1] == 'i')  // disp string  Displacement map
                 else if (buffer[1] == 'i')  // disp string  Displacement map
                 {
                 {
@@ -2330,13 +2325,13 @@ static Material LoadMTL(const char *fileName)
             case 'b':   // bump string      Bump texture map
             case 'b':   // bump string      Bump texture map
             {
             {
                 result = sscanf(buffer, "bump %s", mapFileName);
                 result = sscanf(buffer, "bump %s", mapFileName);
-                if (result != EOF) material.maps[TEXMAP_NORMAL].tex = LoadTexture(mapFileName);
+                if (result != EOF) material.maps[MAP_NORMAL].texture = LoadTexture(mapFileName);
             } break;
             } break;
             case 'T':   // Tr float         Transparency Tr (alpha). Tr is inverse of d
             case 'T':   // Tr float         Transparency Tr (alpha). Tr is inverse of d
             {
             {
                 float ialpha = 0.0f;
                 float ialpha = 0.0f;
                 sscanf(buffer, "Tr %f", &ialpha);
                 sscanf(buffer, "Tr %f", &ialpha);
-                material.maps[TEXMAP_DIFFUSE].color.a = (unsigned char)((1.0f - ialpha)*255);
+                material.maps[MAP_DIFFUSE].color.a = (unsigned char)((1.0f - ialpha)*255);
 
 
             } break;
             } break;
             case 'r':   // refl string      Reflection texture map
             case 'r':   // refl string      Reflection texture map

+ 58 - 52
src/raylib.h

@@ -292,9 +292,8 @@
 #define RAYWHITE   CLITERAL{ 245, 245, 245, 255 }   // My own White (raylib logo)
 #define RAYWHITE   CLITERAL{ 245, 245, 245, 255 }   // My own White (raylib logo)
 
 
 // Shader and material limits
 // Shader and material limits
-#define MAX_SHADER_LOCATIONS        32
-#define MAX_MATERIAL_TEXTURE_MAPS   12
-#define MAX_MATERIAL_PARAMS          8
+#define MAX_SHADER_LOCATIONS        32      // Maximum number of predefined locations stored in shader struct
+#define MAX_MATERIAL_MAPS           12      // Maximum number of texture maps stored in shader struct
 
 
 //----------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------
 // Structures Definition
 // Structures Definition
@@ -405,21 +404,22 @@ typedef struct Camera2D {
 
 
 // Bounding box type
 // Bounding box type
 typedef struct BoundingBox {
 typedef struct BoundingBox {
-    Vector3 min;            // minimum vertex box-corner
-    Vector3 max;            // maximum vertex box-corner
+    Vector3 min;            // Minimum vertex box-corner
+    Vector3 max;            // Maximum vertex box-corner
 } BoundingBox;
 } BoundingBox;
 
 
 // Vertex data definning a mesh
 // Vertex data definning a mesh
 typedef struct Mesh {
 typedef struct Mesh {
-    int vertexCount;        // number of vertices stored in arrays
-    int triangleCount;      // number of triangles stored (indexed or not)
-    float *vertices;        // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
-    float *texcoords;       // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
-    float *texcoords2;      // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
-    float *normals;         // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
-    float *tangents;        // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
-    unsigned char *colors;  // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
-    unsigned short *indices;// vertex indices (in case vertex data comes indexed)
+    int vertexCount;        // Number of vertices stored in arrays
+    int triangleCount;      // Number of triangles stored (indexed or not)
+    
+    float *vertices;        // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
+    float *texcoords;       // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
+    float *texcoords2;      // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
+    float *normals;         // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
+    float *tangents;        // Vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
+    unsigned char *colors;  // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
+    unsigned short *indices;// Vertex indices (in case vertex data comes indexed)
 
 
     unsigned int vaoId;     // OpenGL Vertex Array Object id
     unsigned int vaoId;     // OpenGL Vertex Array Object id
     unsigned int vboId[7];  // OpenGL Vertex Buffer Objects id (7 types of vertex data)
     unsigned int vboId[7];  // OpenGL Vertex Buffer Objects id (7 types of vertex data)
@@ -427,22 +427,22 @@ typedef struct Mesh {
 
 
 // Shader type (generic)
 // Shader type (generic)
 typedef struct Shader {
 typedef struct Shader {
-    unsigned int id;        // Shader program id
-    int locs[MAX_SHADER_LOCATIONS];             // Initialized on LoadShader(), set to MAX_SHADER_LOCATIONS
+    unsigned int id;                // Shader program id
+    int locs[MAX_SHADER_LOCATIONS]; // Shader locations array
 } Shader;
 } Shader;
 
 
 // Material texture map
 // Material texture map
-typedef struct TextureMap {
-    Texture2D tex;
-    Color color;
-    float value;
-} TextureMap;
+typedef struct MaterialMap {
+    Texture2D texture;      // Material map texture
+    Color color;            // Material map color
+    float value;            // Material map value
+} MaterialMap;
 
 
 // Material type (generic)
 // Material type (generic)
 typedef struct Material {
 typedef struct Material {
-    Shader shader;
-    TextureMap maps[MAX_MATERIAL_TEXTURE_MAPS]; // Initialized on LoadMaterial*(), set to MAX_MATERIAL_TEXTURE_MAPS
-    float *params;          // Initialized on LoadMaterial*(), set to MAX_MATERIAL_PARAMS
+    Shader shader;          // Material shader
+    MaterialMap maps[MAX_MATERIAL_MAPS]; // Material maps
+    float *params;          // Material generic parameters (if required)
 } Material;
 } Material;
 
 
 // Model type
 // Model type
@@ -526,6 +526,7 @@ typedef enum {
     LOG_OTHER 
     LOG_OTHER 
 } LogType;
 } LogType;
 
 
+// Shader location point type
 typedef enum {
 typedef enum {
     LOC_VERTEX_POSITION = 0,
     LOC_VERTEX_POSITION = 0,
     LOC_VERTEX_TEXCOORD01,
     LOC_VERTEX_TEXCOORD01,
@@ -541,38 +542,39 @@ typedef enum {
     LOC_COLOR_DIFFUSE,
     LOC_COLOR_DIFFUSE,
     LOC_COLOR_SPECULAR,
     LOC_COLOR_SPECULAR,
     LOC_COLOR_AMBIENT,
     LOC_COLOR_AMBIENT,
-    LOC_TEXMAP_ALBEDO,          // LOC_TEXMAP_DIFFUSE
-    LOC_TEXMAP_METALNESS,       // LOC_TEXMAP_SPECULAR
-    LOC_TEXMAP_NORMAL,
-    LOC_TEXMAP_ROUGHNESS,
-    LOC_TEXMAP_OCCUSION,
-    LOC_TEXMAP_EMISSION,
-    LOC_TEXMAP_HEIGHT,
-    LOC_TEXMAP_CUBEMAP,
-    LOC_TEXMAP_IRRADIANCE,
-    LOC_TEXMAP_PREFILTER,
-    LOC_TEXMAP_BRDF
+    LOC_MAP_ALBEDO,          // LOC_MAP_DIFFUSE
+    LOC_MAP_METALNESS,       // LOC_MAP_SPECULAR
+    LOC_MAP_NORMAL,
+    LOC_MAP_ROUGHNESS,
+    LOC_MAP_OCCUSION,
+    LOC_MAP_EMISSION,
+    LOC_MAP_HEIGHT,
+    LOC_MAP_CUBEMAP,
+    LOC_MAP_IRRADIANCE,
+    LOC_MAP_PREFILTER,
+    LOC_MAP_BRDF
 } ShaderLocationIndex;
 } ShaderLocationIndex;
 
 
-#define LOC_TEXMAP_DIFFUSE      LOC_TEXMAP_ALBEDO
-#define LOC_TEXMAP_SPECULAR     LOC_TEXMAP_METALNESS
+#define LOC_MAP_DIFFUSE      LOC_MAP_ALBEDO
+#define LOC_MAP_SPECULAR     LOC_MAP_METALNESS
 
 
+// Material map type
 typedef enum {
 typedef enum {
-    TEXMAP_ALBEDO    = 0,       // TEXMAP_DIFFUSE
-    TEXMAP_METALNESS = 1,       // TEXMAP_SPECULAR
-    TEXMAP_NORMAL    = 2,
-    TEXMAP_ROUGHNESS = 3,
-    TEXMAP_OCCLUSION,
-    TEXMAP_EMISSION,
-    TEXMAP_HEIGHT,
-    TEXMAP_CUBEMAP,             // NOTE: Uses GL_TEXTURE_CUBE_MAP
-    TEXMAP_IRRADIANCE,          // NOTE: Uses GL_TEXTURE_CUBE_MAP
-    TEXMAP_PREFILTER,           // NOTE: Uses GL_TEXTURE_CUBE_MAP
-    TEXMAP_BRDF
+    MAP_ALBEDO    = 0,       // MAP_DIFFUSE
+    MAP_METALNESS = 1,       // MAP_SPECULAR
+    MAP_NORMAL    = 2,
+    MAP_ROUGHNESS = 3,
+    MAP_OCCLUSION,
+    MAP_EMISSION,
+    MAP_HEIGHT,
+    MAP_CUBEMAP,             // NOTE: Uses GL_TEXTURE_CUBE_MAP
+    MAP_IRRADIANCE,          // NOTE: Uses GL_TEXTURE_CUBE_MAP
+    MAP_PREFILTER,           // NOTE: Uses GL_TEXTURE_CUBE_MAP
+    MAP_BRDF
 } TexmapIndex;
 } TexmapIndex;
 
 
-#define TEXMAP_DIFFUSE      TEXMAP_ALBEDO
-#define TEXMAP_SPECULAR     TEXMAP_METALNESS
+#define MAP_DIFFUSE      MAP_ALBEDO
+#define MAP_SPECULAR     MAP_METALNESS
 
 
 // Texture formats
 // Texture formats
 // NOTE: Support depends on OpenGL version and platform
 // NOTE: Support depends on OpenGL version and platform
@@ -1037,8 +1039,6 @@ 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);              // Generate cubemap texture map from HDR texture
-
 // 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)
@@ -1047,6 +1047,12 @@ RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat);
 RLAPI void SetMatrixProjection(Matrix proj);                              // Set a custom projection matrix (replaces internal projection matrix)
 RLAPI void SetMatrixProjection(Matrix proj);                              // Set a custom projection matrix (replaces internal projection matrix)
 RLAPI void SetMatrixModelview(Matrix view);                               // Set a custom modelview matrix (replaces internal modelview matrix)
 RLAPI void SetMatrixModelview(Matrix view);                               // Set a custom modelview matrix (replaces internal modelview matrix)
 
 
+// Texture maps generation (PBR)
+RLAPI Texture2D GenTextureCubemap(Texture2D skyHDR, int size);            // Generate cubemap texture from HDR texture
+RLAPI Texture2D GenTextureIrradiance(Texture2D cubemap, int size);        // Generate irradiance texture using cubemap data
+RLAPI Texture2D GenTexturePrefilter(Texture2D cubemap, int size);         // Generate prefilter texture using cubemap data
+RLAPI Texture2D GenTextureBRDF(Texture2D cubemap, int size);              // Generate BRDF texture using cubemap data
+
 // Shading begin/end functions
 // Shading begin/end functions
 RLAPI void BeginShaderMode(Shader shader);                                // Begin custom shader drawing
 RLAPI void BeginShaderMode(Shader shader);                                // Begin custom shader drawing
 RLAPI void EndShaderMode(void);                                           // End custom shader drawing (use default shader)
 RLAPI void EndShaderMode(void);                                           // End custom shader drawing (use default shader)

File diff suppressed because it is too large
+ 390 - 491
src/rlgl.c


+ 44 - 40
src/rlgl.h

@@ -146,6 +146,7 @@ typedef unsigned char byte;
     typedef enum { false, true } bool;
     typedef enum { false, true } bool;
     #endif
     #endif
     
     
+    // Shader location point type
     typedef enum {
     typedef enum {
         LOC_VERTEX_POSITION = 0,
         LOC_VERTEX_POSITION = 0,
         LOC_VERTEX_TEXCOORD01,
         LOC_VERTEX_TEXCOORD01,
@@ -161,38 +162,39 @@ typedef unsigned char byte;
         LOC_COLOR_DIFFUSE,
         LOC_COLOR_DIFFUSE,
         LOC_COLOR_SPECULAR,
         LOC_COLOR_SPECULAR,
         LOC_COLOR_AMBIENT,
         LOC_COLOR_AMBIENT,
-        LOC_TEXMAP_ALBEDO,          // LOC_TEXMAP_DIFFUSE
-        LOC_TEXMAP_METALNESS,       // LOC_TEXMAP_SPECULAR
-        LOC_TEXMAP_NORMAL,
-        LOC_TEXMAP_ROUGHNESS,
-        LOC_TEXMAP_OCCUSION,
-        LOC_TEXMAP_EMISSION,
-        LOC_TEXMAP_HEIGHT,
-        LOC_TEXMAP_CUBEMAP,
-        LOC_TEXMAP_IRRADIANCE,
-        LOC_TEXMAP_PREFILTER,
-        LOC_TEXMAP_BRDF
+        LOC_MAP_ALBEDO,          // LOC_MAP_DIFFUSE
+        LOC_MAP_METALNESS,       // LOC_MAP_SPECULAR
+        LOC_MAP_NORMAL,
+        LOC_MAP_ROUGHNESS,
+        LOC_MAP_OCCUSION,
+        LOC_MAP_EMISSION,
+        LOC_MAP_HEIGHT,
+        LOC_MAP_CUBEMAP,
+        LOC_MAP_IRRADIANCE,
+        LOC_MAP_PREFILTER,
+        LOC_MAP_BRDF
     } ShaderLocationIndex;
     } ShaderLocationIndex;
 
 
-    #define LOC_TEXMAP_DIFFUSE      LOC_TEXMAP_ALBEDO
-    #define LOC_TEXMAP_SPECULAR     LOC_TEXMAP_METALNESS
+    #define LOC_MAP_DIFFUSE      LOC_MAP_ALBEDO
+    #define LOC_MAP_SPECULAR     LOC_MAP_METALNESS
 
 
+    // Material map type
     typedef enum {
     typedef enum {
-        TEXMAP_ALBEDO    = 0,       // TEXMAP_DIFFUSE
-        TEXMAP_METALNESS = 1,       // TEXMAP_SPECULAR
-        TEXMAP_NORMAL    = 2,
-        TEXMAP_ROUGHNESS = 3,
-        TEXMAP_OCCLUSION,
-        TEXMAP_EMISSION,
-        TEXMAP_HEIGHT,
-        TEXMAP_CUBEMAP,             // NOTE: Uses GL_TEXTURE_CUBE_MAP
-        TEXMAP_IRRADIANCE,          // NOTE: Uses GL_TEXTURE_CUBE_MAP
-        TEXMAP_PREFILTER,           // NOTE: Uses GL_TEXTURE_CUBE_MAP
-        TEXMAP_BRDF
+        MAP_ALBEDO    = 0,       // MAP_DIFFUSE
+        MAP_METALNESS = 1,       // MAP_SPECULAR
+        MAP_NORMAL    = 2,
+        MAP_ROUGHNESS = 3,
+        MAP_OCCLUSION,
+        MAP_EMISSION,
+        MAP_HEIGHT,
+        MAP_CUBEMAP,             // NOTE: Uses GL_TEXTURE_CUBE_MAP
+        MAP_IRRADIANCE,          // NOTE: Uses GL_TEXTURE_CUBE_MAP
+        MAP_PREFILTER,           // NOTE: Uses GL_TEXTURE_CUBE_MAP
+        MAP_BRDF
     } TexmapIndex;
     } TexmapIndex;
 
 
-    #define TEXMAP_DIFFUSE      TEXMAP_ALBEDO
-    #define TEXMAP_SPECULAR     TEXMAP_METALNESS
+    #define MAP_DIFFUSE      MAP_ALBEDO
+    #define MAP_SPECULAR     MAP_METALNESS
 
 
     // Color type, RGBA (32bit)
     // Color type, RGBA (32bit)
     typedef struct Color {
     typedef struct Color {
@@ -237,8 +239,7 @@ typedef unsigned char byte;
     
     
     // Shader and material limits
     // Shader and material limits
     #define MAX_SHADER_LOCATIONS        32
     #define MAX_SHADER_LOCATIONS        32
-    #define MAX_MATERIAL_TEXTURE_MAPS   12
-    #define MAX_MATERIAL_PARAMS          8
+    #define MAX_MATERIAL_MAPS   12
     
     
     // Shader type (generic)
     // Shader type (generic)
     typedef struct Shader {
     typedef struct Shader {
@@ -247,16 +248,16 @@ typedef unsigned char byte;
     } Shader;
     } Shader;
 
 
     // Material texture map
     // Material texture map
-    typedef struct TextureMap {
+    typedef struct MaterialMap {
         Texture2D tex;
         Texture2D tex;
         Color color;
         Color color;
         float value;
         float value;
-    } TextureMap;
+    } MaterialMap;
 
 
     // Material type (generic)
     // Material type (generic)
     typedef struct Material {
     typedef struct Material {
         Shader shader;
         Shader shader;
-        TextureMap maps[MAX_TEXTURE_MAPS];  // Initialized on LoadMaterial*(), set to MAX_TEXTURE_MAPS
+        MaterialMap maps[MAX_TEXTURE_MAPS];  // Initialized on LoadMaterial*(), set to MAX_TEXTURE_MAPS
         float *params;          // Initialized on LoadMaterial*(), set to MAX_MATERIAL_PARAMS
         float *params;          // Initialized on LoadMaterial*(), set to MAX_MATERIAL_PARAMS
     } Material;
     } Material;
 
 
@@ -400,9 +401,10 @@ Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view);  // Get world coo
 // Functions Declaration - rlgl functionality
 // Functions Declaration - rlgl functionality
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 void rlglInit(int width, int height);           // Initialize rlgl (buffers, shaders, textures, states)
 void rlglInit(int width, int height);           // Initialize rlgl (buffers, shaders, textures, states)
-void rlglClose(void);                           // De-init rlgl
-void rlglDraw(void);                            // Draw VAO/VBO
-void rlglLoadExtensions(void *loader);          // Load OpenGL extensions
+void rlglClose(void);                           // De-inititialize rlgl (buffers, shaders, textures)
+void rlglDraw(void);                // Update and Draw default buffers (lines, triangles, quads)
+
+void rlLoadExtensions(void *loader);            // Load OpenGL extensions
 
 
 // Textures data management
 // Textures data management
 unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount);    // Load texture in GPU
 unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount);    // Load texture in GPU
@@ -419,12 +421,6 @@ void rlUpdateMesh(Mesh mesh, int buffer, int numVertex);            // Update ve
 void rlDrawMesh(Mesh mesh, Material material, Matrix transform);    // Draw a 3d mesh with material and transform
 void rlDrawMesh(Mesh mesh, Material material, Matrix transform);    // Draw a 3d mesh with material and transform
 void rlUnloadMesh(Mesh *mesh);                                      // Unload mesh data from CPU and GPU
 void rlUnloadMesh(Mesh *mesh);                                      // Unload mesh data from CPU and GPU
 
 
-// Texture maps generation (PBR)
-Texture2D rlGenMapCubemap(Texture2D skyHDR, int size);              // Generate cubemap texture map from HDR texture
-Texture2D rlGenMapIrradiance(Texture2D cubemap, int size);          // Generate irradiance texture map
-Texture2D rlGenMapPrefilter(Texture2D cubemap, int size);           // Generate prefilter texture map
-Texture2D rlGenMapBRDF(Texture2D cubemap, int size);                // Generate BRDF texture map
-
 // NOTE: There is a set of shader related functions that are available to end user,
 // NOTE: There is a set of shader related functions that are available to end user,
 // to avoid creating function wrappers through core module, they have been directly declared in raylib.h
 // to avoid creating function wrappers through core module, they have been directly declared in raylib.h
 
 
@@ -447,11 +443,19 @@ void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat);       // S
 void SetMatrixProjection(Matrix proj);                  // Set a custom projection matrix (replaces internal projection matrix)
 void SetMatrixProjection(Matrix proj);                  // Set a custom projection matrix (replaces internal projection matrix)
 void SetMatrixModelview(Matrix view);                   // Set a custom modelview matrix (replaces internal modelview matrix)
 void SetMatrixModelview(Matrix view);                   // Set a custom modelview matrix (replaces internal modelview matrix)
 
 
+// Texture maps generation (PBR)
+Texture2D GenTextureCubemap(Texture2D skyHDR, int size);            // Generate cubemap texture map from HDR texture
+Texture2D GenTextureIrradiance(Texture2D cubemap, int size);        // Generate irradiance texture map
+Texture2D GenTexturePrefilter(Texture2D cubemap, int size);         // Generate prefilter texture map
+Texture2D GenTextureBRDF(Texture2D cubemap, int size);              // Generate BRDF texture map
+
+// Shading and blending
 void BeginShaderMode(Shader shader);                    // Begin custom shader drawing
 void BeginShaderMode(Shader shader);                    // Begin custom shader drawing
 void EndShaderMode(void);                               // End custom shader drawing (use default shader)
 void EndShaderMode(void);                               // End custom shader drawing (use default shader)
 void BeginBlendMode(int mode);                          // Begin blending mode (alpha, additive, multiplied)
 void BeginBlendMode(int mode);                          // Begin blending mode (alpha, additive, multiplied)
 void EndBlendMode(void);                                // End blending mode (reset to default: alpha blending)
 void EndBlendMode(void);                                // End blending mode (reset to default: alpha blending)
 
 
+// VR simulator functionality
 void InitVrSimulator(int vrDevice);                     // Init VR simulator for selected device
 void InitVrSimulator(int vrDevice);                     // Init VR simulator for selected device
 void CloseVrSimulator(void);                            // Close VR simulator for current device
 void CloseVrSimulator(void);                            // Close VR simulator for current device
 void UpdateVrTracking(Camera *camera);                  // Update VR tracking (position and orientation) and camera
 void UpdateVrTracking(Camera *camera);                  // Update VR tracking (position and orientation) and camera

Some files were not shown because too many files changed in this diff