PBR, fixed the way metallic material base color was handled for indirect lighting.

Also calibrated roughness so that it matches Substance painter renderer.
define_list_fix
Nehon 9 years ago
parent 1276dc583e
commit 9e1a1f6131
  1. 7
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  2. 4
      jme3-core/src/main/resources/Common/ShaderLib/PBR.glsllib

@ -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;
@ -118,7 +118,7 @@ void main(){
#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);
@ -234,4 +234,5 @@ void main(){
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…
Cancel
Save