mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
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 NdotV = dot(N, V);
|
||||||
float cNdotV = max(NdotV, 0.0);
|
float cNdotV = max(NdotV, 0.0);
|
||||||
|
|
||||||
|
if (metallic < 1.0) {
|
||||||
#if defined(DIFFUSE_OREN_NAYAR)
|
#if defined(DIFFUSE_OREN_NAYAR)
|
||||||
vec3 diffuse_brdf_NL;
|
vec3 diffuse_brdf_NL;
|
||||||
#else
|
#else
|
||||||
|
|
@ -1003,7 +1004,7 @@ LIGHT_SHADER_CODE
|
||||||
float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotV);
|
float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotV);
|
||||||
float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotL);
|
float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotL);
|
||||||
diffuse_brdf_NL = (1.0 / M_PI) * FdV * FdL * cNdotL;
|
diffuse_brdf_NL = (1.0 / M_PI) * FdV * FdL * cNdotL;
|
||||||
/*
|
/*
|
||||||
float energyBias = mix(roughness, 0.0, 0.5);
|
float energyBias = mix(roughness, 0.0, 0.5);
|
||||||
float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
|
float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
|
||||||
float fd90 = energyBias + 2.0 * VoH * VoH * roughness;
|
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);
|
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;
|
diffuse_light += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (roughness > 0.0) {
|
if (roughness < 1.0) {
|
||||||
|
|
||||||
|
|
||||||
// D
|
// D
|
||||||
|
|
@ -1099,7 +1101,7 @@ LIGHT_SHADER_CODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LIGHT_USE_CLEARCOAT)
|
#if defined(LIGHT_USE_CLEARCOAT)
|
||||||
|
if (clearcoat_gloss > 0.0) {
|
||||||
# if !defined(SPECULAR_SCHLICK_GGX) && !defined(SPECULAR_BLINN)
|
# if !defined(SPECULAR_SCHLICK_GGX) && !defined(SPECULAR_BLINN)
|
||||||
vec3 H = normalize(V + L);
|
vec3 H = normalize(V + L);
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -1114,6 +1116,7 @@ LIGHT_SHADER_CODE
|
||||||
|
|
||||||
|
|
||||||
specular_light += .25*clearcoat*Gr*Fr*Dr;
|
specular_light += .25*clearcoat*Gr*Fr*Dr;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1985,7 +1988,7 @@ FRAGMENT_SHADER_CODE
|
||||||
|
|
||||||
|
|
||||||
//energy conservation
|
//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;
|
ambient_light *= 1.0-metallic;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue