PBR, fixed the way metallic material base color was handled for indirect lighting.
Also calibrated roughness so that it matches Substance painter renderer.
This commit is contained in:
parent
1276dc583e
commit
9e1a1f6131
@ -1,5 +1,5 @@
|
||||
#import "Common/ShaderLib/Parallax.glsllib"
|
||||
#import "Common/ShaderLib/PBR.glsllib"
|
||||
#import "ShaderLib/PBR.glsllib"
|
||||
#import "Common/ShaderLib/Lighting.glsllib"
|
||||
|
||||
varying vec2 texCoord;
|
||||
@ -111,14 +111,14 @@ void main(){
|
||||
vec4 albedo = Color;
|
||||
#endif
|
||||
#ifdef ROUGHNESSMAP
|
||||
float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness,1e-8);
|
||||
float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness, 1e-8);
|
||||
#else
|
||||
float Roughness = max(m_Roughness,1e-8);
|
||||
float Roughness = max(m_Roughness, 1e-8);
|
||||
#endif
|
||||
#ifdef METALLICMAP
|
||||
float Metallic = texture2D(m_MetallicMap, newTexCoord).r;
|
||||
#else
|
||||
float Metallic = max(m_Metallic,0.00);
|
||||
float Metallic = max(m_Metallic, 0.0);
|
||||
#endif
|
||||
|
||||
float alpha = Color.a * albedo.a;
|
||||
@ -214,7 +214,7 @@ void main(){
|
||||
|
||||
vec3 indirectDiffuse = vec3(0.0);
|
||||
vec3 indirectSpecular = vec3(0.0);
|
||||
indirectDiffuse = textureCube(g_IrradianceMap, rv.xyz).rgb * albedo.rgb;
|
||||
indirectDiffuse = textureCube(g_IrradianceMap, rv.xyz).rgb * diffuseColor.rgb;
|
||||
|
||||
indirectSpecular = ApproximateSpecularIBLPolynomial(g_PrefEnvMap, specularColor.rgb, Roughness, ndotv, rv.xyz);
|
||||
indirectSpecular *= vec3(horiz);
|
||||
@ -233,5 +233,6 @@ void main(){
|
||||
#endif
|
||||
|
||||
gl_FragColor.a = alpha;
|
||||
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ vec3 EnvDFGPolynomial( vec3 specularColor, float roughness, float ndotv ){
|
||||
|
||||
vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
|
||||
//TODO magic values should be replaced by defines.
|
||||
float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0;
|
||||
float Lod = log2(Roughness) * 1.5 + 6.0 - 1.0;
|
||||
vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz,Lod).rgb;
|
||||
vec2 EnvBRDF = texture2D(integrateBRDF,vec2(Roughness, ndotv)).rg;
|
||||
return PrefilteredColor * ( SpecularColor * EnvBRDF.x+ EnvBRDF.y );
|
||||
@ -142,7 +142,7 @@ vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 Spe
|
||||
|
||||
vec3 ApproximateSpecularIBLPolynomial(samplerCube envMap, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
|
||||
//TODO magic values should be replaced by defines.
|
||||
float Lod = log2(Roughness) * 1.2 + 6.0 - 1.0;
|
||||
float Lod = log2(Roughness) * 1.5 + 6.0 - 1.0;
|
||||
vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz,Lod).rgb;
|
||||
return PrefilteredColor * EnvDFGPolynomial(SpecularColor, Roughness, ndotv);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user