Hello Everyone,
I am trying to render a wall in OpenGL using (diffuse, normal and specular) maps and here is the results:
[ATTACH=CONFIG]1676[/ATTACH]
with this shader:
fragment shader:
uniform sampler2D diffuseMap1;
uniform sampler2D normalMap1;
uniform sampler2D specularMap1;
uniform sampler2D shadowMap;
in VS_OUT1 {
vec3 TangentFragPos;
vec3 TangentViewPos;
mat3 TBN;
} fs_in1;
in VS_OUT2 {
vec3 Normal;
vec3 FragPos;
vec2 TexCoords;
vec3 ViewPos;
vec4 FragPosLightSpace;
} fs_in2;
struct Material {
vec3 ambi;
vec3 diff;
vec3 spec;
};
struct DirLight {
vec3 dir;
Material mat;
};
uniform DirLight dL;
float ShadowCalculation(sampler2D shadowMap, vec4 fragPosLightSpace)
{ ....... }
vec3 CalcDirLight(DirLight light, mat3 TBN, vec3 viewDir, vec3 color, vec3 normal, vec3 specular, float shadowAmount);
void main()
{
vec3 color = texture(diffuseMap1, fs_in2.TexCoords).rgb;
vec3 normal = texture(normalMap1, fs_in2.TexCoords).rgb * 2.0 - 1.0;
vec3 specular = texture(specularMap1, fs_in2.TexCoords).rgb;
float shadow = ShadowCalculation(shadowMap, fs_in2.FragPosLightSpace);
vec3 tangentViewDir = normalize(fs_in1.TangentViewPos - fs_in1.TangentFragPos);
vec3 resultFromDirLight = CalcDirLight(dL, fs_in1.TBN, tangentViewDir, color, normal, specular, shadow, normals);
vec3 result = resultFromDirLight;
FragColor = vec4(result, 1.0);
}
vec3 CalcDirLight(DirLight light, mat3 TBN, vec3 viewDir, vec3 color, vec3 normal, vec3 specular, float shadowAmount)
{
vec3 lightDir = TBN * light.dir;
float diff = max(dot(normal, lightDir), 0.0);
vec3 halfwayDir = normalize(lightDir + viewDir);
vec3 specularAmount = vec3(pow(max(dot(viewDir, halfwayDir), 0.0), 64.0));
vec3 ambient = light.mat.ambi * color;
vec3 diffuse = light.mat.diff * diff * color;
specularAmount *= light.mat.spec * specular;
return (ambient + shadowAmount * (diffuse + specularAmount));
}
And also tried to render the same wall in Blender with the same 3 textures, and here is the results:
[ATTACH=CONFIG]1677[/ATTACH]
You notice the big difference, how can I achieve this amazing quality of rendering? any help please.
DiffuseMap:[ATTACH=CONFIG]1678[/ATTACH]
NormalMap:[ATTACH=CONFIG]1679[/ATTACH]
SpecularMap:[ATTACH=CONFIG]1680[/ATTACH]
BlenderFile:https://drive.google.com/open?id=1Ey1RK1Mt9vw-tsh9kpEYJ-bgIxBkTvkm