diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index 8d4e01b25..9380bd911 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -94,7 +94,7 @@ int main() // Send to material PBR shader camera view position float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; - SetShaderValue(model.material.shader, model.material.shader.locs[LOC_MATRIX_VIEW], cameraPos, 3); + SetShaderValue(model.material.shader, model.material.shader.locs[LOC_VECTOR_VIEW], cameraPos, 3); //---------------------------------------------------------------------------------- // Draw diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 67087ef4e..8b302b1c3 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -34,13 +34,13 @@ int main() SetShaderValuei(skybox.material.shader, GetShaderLocation(skybox.material.shader, "environmentMap"), (int[1]){ TEXMAP_CUBEMAP }, 1); // Get skybox shader locations - int skyProjectionLoc = GetShaderLocation(skybox.material.shader, "projection"); + skybox.material.shader.locs[LOC_MATRIX_PROJECTION] = GetShaderLocation(skybox.material.shader, "projection"); skybox.material.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(skybox.material.shader, "view"); - + // Then before rendering, configure the viewport to the actual screen dimensions Matrix proj = MatrixPerspective(60.0, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0); MatrixTranspose(&proj); - SetShaderValueMatrix(skybox.material.shader, skyProjectionLoc, proj); + SetShaderValueMatrix(skybox.material.shader, skybox.material.shader.locs[LOC_MATRIX_PROJECTION], proj); SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode diff --git a/src/models.c b/src/models.c index 6f1955200..1f49977ea 100644 --- a/src/models.c +++ b/src/models.c @@ -1319,7 +1319,8 @@ Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float rou mat.shader.locs[LOC_TEXMAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT"); // Set view matrix location - mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "viewPos"); + mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view"); + mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos"); // Set up material properties color mat.maps[TEXMAP_ALBEDO].color = albedo; diff --git a/src/raylib.h b/src/raylib.h index 4115d6366..09d35479b 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -536,6 +536,7 @@ typedef enum { LOC_MATRIX_MVP, LOC_MATRIX_VIEW, LOC_MATRIX_PROJECTION, + LOC_VECTOR_VIEW, LOC_COLOR_DIFFUSE, LOC_COLOR_SPECULAR, LOC_COLOR_AMBIENT, @@ -1027,7 +1028,7 @@ RLAPI void UnloadShader(Shader shader); // Unl RLAPI Shader GetShaderDefault(void); // Get default shader RLAPI Texture2D GetTextureDefault(void); // Get default texture -RLAPI Texture2D rlGenMapCubemap(Texture2D skyHDR, int size); +RLAPI Texture2D rlGenMapCubemap(Texture2D skyHDR, int size); // Generate cubemap texture map from HDR texture // Shader configuration functions RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location diff --git a/src/rlgl.h b/src/rlgl.h index 6ac7bbeaa..9fbbd4c94 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -150,46 +150,48 @@ typedef unsigned char byte; LOC_VERTEX_POSITION = 0, LOC_VERTEX_TEXCOORD01, LOC_VERTEX_TEXCOORD02, - LOC_VERTEX_TEXCOORD03, - LOC_VERTEX_TEXCOORD04, LOC_VERTEX_NORMAL, LOC_VERTEX_TANGENT, LOC_VERTEX_COLOR, LOC_MATRIX_MVP, LOC_MATRIX_VIEW, LOC_MATRIX_PROJECTION, - LOC_TEXTURE_MAP01, - LOC_TEXTURE_MAP02, - LOC_TEXTURE_MAP03, - LOC_TEXTURE_MAP04, - LOC_TEXTURE_MAP05, - LOC_TEXTURE_MAP06, - LOC_TEXTURE_MAP07, - LOC_TEXTURE_MAP08, - LOC_TEXTURE_COLOR01, - LOC_TEXTURE_COLOR02, - LOC_TEXTURE_COLOR03, - LOC_TEXTURE_COLOR04, - LOC_TEXTURE_COLOR05, - LOC_TEXTURE_COLOR06, - LOC_TEXTURE_COLOR07, - LOC_TEXTURE_COLOR08 + LOC_VECTOR_VIEW, + LOC_COLOR_DIFFUSE, + LOC_COLOR_SPECULAR, + 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 } ShaderLocationIndex; - typedef enum { - TEXMAP_DIFFUSE = 0, - TEXMAP_SPECULAR = 1, - TEXMAP_NORMAL = 2, - } TexmapBasicIndex; + #define LOC_TEXMAP_DIFFUSE LOC_TEXMAP_ALBEDO + #define LOC_TEXMAP_SPECULAR LOC_TEXMAP_METALNESS typedef enum { - TEXMAP_ALBEDO = 0, - TEXMAP_METALNESS = 1, + TEXMAP_ALBEDO = 0, // TEXMAP_DIFFUSE + TEXMAP_METALNESS = 1, // TEXMAP_SPECULAR + TEXMAP_NORMAL = 2, TEXMAP_ROUGHNESS = 3, TEXMAP_OCCLUSION, TEXMAP_EMISSION, - TEXMAP_HEIGHT - } TexmapPBRIndex; + 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 + } TexmapIndex; + + #define TEXMAP_DIFFUSE TEXMAP_ALBEDO + #define TEXMAP_SPECULAR TEXMAP_METALNESS // Color type, RGBA (32bit) typedef struct Color { @@ -417,7 +419,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d 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 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