Fixed an outstanding issue with PBR lighting that was screwing reflection with normal maps.

This commit is contained in:
Nehon 2015-11-19 19:05:20 +01:00
parent 31d271d972
commit f010f1be59

View File

@ -135,7 +135,7 @@ vec3 EnvDFGPolynomial( vec3 specularColor, float roughness, float ndotv ){
vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){ vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
//TODO magic values should be replaced by defines. //TODO magic values should be replaced by defines.
float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0; float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0;
vec3 PrefilteredColor = textureCube(envMap, refVec.xyz,Lod).rgb; vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz,Lod).rgb;
vec2 EnvBRDF = texture2D(integrateBRDF,vec2(Roughness, ndotv)).rg; vec2 EnvBRDF = texture2D(integrateBRDF,vec2(Roughness, ndotv)).rg;
return PrefilteredColor * ( SpecularColor * EnvBRDF.x+ EnvBRDF.y ); return PrefilteredColor * ( SpecularColor * EnvBRDF.x+ EnvBRDF.y );
} }
@ -143,7 +143,7 @@ vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 Spe
vec3 ApproximateSpecularIBLPolynomial(samplerCube envMap, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){ vec3 ApproximateSpecularIBLPolynomial(samplerCube envMap, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
//TODO magic values should be replaced by defines. //TODO magic values should be replaced by defines.
float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0; float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0;
vec3 PrefilteredColor = textureCube(envMap, refVec.xyz,Lod).rgb; vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz,Lod).rgb;
return PrefilteredColor * EnvDFGPolynomial(SpecularColor, Roughness, ndotv); return PrefilteredColor * EnvDFGPolynomial(SpecularColor, Roughness, ndotv);
} }