Merge pull request #11807 from tagcup/roughness_metallic_limiting_cases
Fix the condition when specular light calculation is avoided (should …
This commit is contained in:
commit
a2a4f9a62a
1 changed files with 51 additions and 48 deletions
|
@ -959,6 +959,7 @@ LIGHT_SHADER_CODE
|
|||
float NdotV = dot(N, V);
|
||||
float cNdotV = max(NdotV, 0.0);
|
||||
|
||||
if (metallic < 1.0) {
|
||||
#if defined(DIFFUSE_OREN_NAYAR)
|
||||
vec3 diffuse_brdf_NL;
|
||||
#else
|
||||
|
@ -1003,7 +1004,7 @@ LIGHT_SHADER_CODE
|
|||
float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotV);
|
||||
float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotL);
|
||||
diffuse_brdf_NL = (1.0 / M_PI) * FdV * FdL * cNdotL;
|
||||
/*
|
||||
/*
|
||||
float energyBias = mix(roughness, 0.0, 0.5);
|
||||
float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
|
||||
float fd90 = energyBias + 2.0 * VoH * VoH * roughness;
|
||||
|
@ -1030,9 +1031,10 @@ LIGHT_SHADER_CODE
|
|||
float rim_light = pow(1.0-cNdotV, (1.0-roughness)*16.0);
|
||||
diffuse_light += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (roughness > 0.0) {
|
||||
if (roughness < 1.0) {
|
||||
|
||||
|
||||
// D
|
||||
|
@ -1099,7 +1101,7 @@ LIGHT_SHADER_CODE
|
|||
#endif
|
||||
|
||||
#if defined(LIGHT_USE_CLEARCOAT)
|
||||
|
||||
if (clearcoat_gloss > 0.0) {
|
||||
# if !defined(SPECULAR_SCHLICK_GGX) && !defined(SPECULAR_BLINN)
|
||||
vec3 H = normalize(V + L);
|
||||
# endif
|
||||
|
@ -1114,6 +1116,7 @@ LIGHT_SHADER_CODE
|
|||
|
||||
|
||||
specular_light += .25*clearcoat*Gr*Fr*Dr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1985,7 +1988,7 @@ FRAGMENT_SHADER_CODE
|
|||
|
||||
|
||||
//energy conservation
|
||||
diffuse_light *= 1.0-metallic; // TODO: avoid diffuse and ambient light calculations when metallic == 1
|
||||
diffuse_light *= 1.0-metallic; // TODO: avoid all diffuse and ambient light calculations when metallic == 1 up to this point
|
||||
ambient_light *= 1.0-metallic;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue