Keep working on PBR...
This commit is contained in:
parent
28679e3c79
commit
dc45f43855
|
|
@ -32,24 +32,22 @@ int main()
|
|||
|
||||
//model.material.maps[TEXMAP_ALBEDO].tex = LoadTexture("resources/pbr/trooper_albedo.png");
|
||||
SetMaterialTexture(&model.material, TEXMAP_ALBEDO, LoadTexture("resources/pbr/trooper_albedo.png"));
|
||||
/*
|
||||
SetMaterialTexture(&model.material, TEXMAP_NORMAL, LoadTexture("resources/pbr/trooper_normals.png"));
|
||||
SetTextureFilter(model.material.maps[TEXMAP_NORMAL].tex, FILTER_BILINEAR);
|
||||
|
||||
SetMaterialTexture(&model.material, TEXMAP_METALNESS, LoadTexture("resources/pbr/trooper_metalness.png"));
|
||||
SetTextureFilter(model.material.maps[TEXMAP_METALNESS].tex, FILTER_BILINEAR);
|
||||
|
||||
SetMaterialTexture(&model.material, TEXMAP_ROUGHNESS, LoadTexture("resources/pbr/trooper_roughness.png"));
|
||||
SetTextureFilter(model.material.maps[TEXMAP_ROUGHNESS].tex, FILTER_BILINEAR);
|
||||
|
||||
SetMaterialTexture(&model.material, TEXMAP_OCCLUSION, LoadTexture("resources/pbr/trooper_ao.png"));
|
||||
|
||||
// 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);
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
//printf("TexMap %i ID: %i\n", i, model.material.maps[i].tex.id);
|
||||
}
|
||||
*/
|
||||
|
||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
|
||||
|
|
@ -62,6 +60,10 @@ int main()
|
|||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera); // Update camera
|
||||
|
||||
// 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);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ uniform samplerCube irradianceMap;
|
|||
uniform samplerCube prefilterMap;
|
||||
uniform sampler2D brdfLUT;
|
||||
|
||||
//uniform sampler2D albedo;
|
||||
//uniform sampler2D normals;
|
||||
//uniform sampler2D metalness;
|
||||
|
||||
// Input lighting values
|
||||
uniform Light lights[MAX_LIGHTS];
|
||||
|
||||
|
|
@ -185,8 +181,10 @@ void main()
|
|||
vec3 refl = reflect(-view, normal);
|
||||
|
||||
// Check if parallax mapping is enabled and calculate texture coordinates to use based on height map
|
||||
if (height.useSampler == 1) texCoord = ParallaxMapping(fragTexCoord, view);
|
||||
else texCoord = fragTexCoord; // Use default texture coordinates
|
||||
//if (height.useSampler == 1) texCoord = ParallaxMapping(fragTexCoord, view);
|
||||
//else texCoord = fragTexCoord; // Use default texture coordinates
|
||||
|
||||
texCoord = fragTexCoord; // Use default texture coordinates
|
||||
|
||||
// Fetch material values from texture sampler or color attributes
|
||||
vec3 color = pow(texture(albedo.sampler, texCoord).rgb, vec3(2.2));//pow(ComputeMaterialProperty(albedo), vec3(2.2));
|
||||
|
|
@ -195,8 +193,6 @@ void main()
|
|||
vec3 emiss = texture(emission.sampler, texCoord).rgb; //ComputeMaterialProperty(emission);
|
||||
vec3 ao = texture(occlusion.sampler, texCoord).rgb; //ComputeMaterialProperty(occlusion);
|
||||
|
||||
vec3 all = color + metal + rough + emiss + ao;
|
||||
|
||||
// Check if normal mapping is enabled
|
||||
if (normals.useSampler == 1)
|
||||
{
|
||||
|
|
@ -300,5 +296,5 @@ void main()
|
|||
fragmentColor = pow(fragmentColor, vec3(1.0/2.2));
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(all, 1.0);//vec4(fragmentColor, 1.0); // It works, so texture is correctly binded!
|
||||
finalColor = vec4(fragmentColor, 1.0); // It works, so texture is correctly binded!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1337,8 +1337,8 @@ Material LoadMaterialPBR(Texture2D hdr, Color albedo, float metalness, float rou
|
|||
|
||||
// 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_IRRADIANCE].tex = rlGenMapIrradiance(cubemap, IRRADIANCE_SIZE);
|
||||
mat.maps[TEXMAP_PREFILTER].tex = rlGenMapPrefilter(cubemap, PREFILTERED_SIZE);
|
||||
mat.maps[TEXMAP_BRDF].tex = rlGenMapBRDF(cubemap, BRDF_SIZE);
|
||||
UnloadTexture(cubemap);
|
||||
|
||||
|
|
|
|||
|
|
@ -1731,8 +1731,9 @@ Texture2D rlGenMapCubemap(Texture2D skyHDR, int size)
|
|||
// Get cubemap shader locations
|
||||
int projectionLoc = GetShaderLocation(shader, "projection");
|
||||
int viewLoc = GetShaderLocation(shader, "view");
|
||||
int texmapLoc = GetShaderLocation(shader, "equirectangularMap");
|
||||
|
||||
SetShaderValuei(shader, GetShaderLocation(shader, "equirectangularMap"), (int[1]){ 0 }, 1);
|
||||
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1); // Set default active texture to 0
|
||||
|
||||
// Set up depth face culling and cubemap seamless
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
|
@ -1816,9 +1817,10 @@ Texture2D rlGenMapIrradiance(Texture2D cubemap, int size)
|
|||
// Get irradiance shader locations
|
||||
int projectionLoc = GetShaderLocation(shader, "projection");
|
||||
int viewLoc = GetShaderLocation(shader, "view");
|
||||
int texmapLoc = GetShaderLocation(shader, "environmentMap");
|
||||
|
||||
// Set up shaders constant values
|
||||
SetShaderValuei(shader, GetShaderLocation(shader, "environmentMap"), (int[1]){ TEXMAP_CUBEMAP }, 1);
|
||||
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1);
|
||||
|
||||
// Setup framebuffer
|
||||
unsigned int fbo, rbo;
|
||||
|
|
@ -1894,8 +1896,9 @@ Texture2D rlGenMapPrefilter(Texture2D cubemap, int size)
|
|||
int projectionLoc = GetShaderLocation(shader, "projection");
|
||||
int viewLoc = GetShaderLocation(shader, "view");
|
||||
int roughnessLoc = GetShaderLocation(shader, "roughness");
|
||||
int texmapLoc = GetShaderLocation(shader, "environmentMap");
|
||||
|
||||
SetShaderValuei(shader, GetShaderLocation(shader, "environmentMap"), (int[1]){ TEXMAP_CUBEMAP }, 1);
|
||||
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1);
|
||||
|
||||
// Setup framebuffer
|
||||
unsigned int fbo, rbo;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user