diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-01 07:54:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 07:54:57 +0200 |
commit | 677f565ce8be3f12dc3698a933592515298c564f (patch) | |
tree | 6d6d3673ea4f4b8ef428f579f2219647e1939bcc /servers | |
parent | 44f1e540f62faf03e64411e1f52c3cb0a31d2758 (diff) | |
parent | 0c65ed38a69c12f293e3718d73915eeeef2a7d83 (diff) |
Merge pull request #63587 from clayjohn/specular-occlusion
Treat specular less than 0.02 as occlusion
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl | 2 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 360ece7f32..22058b3a06 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -1381,7 +1381,7 @@ void fragment_shader(in SceneData scene_data) { float a004 = min(r.x * r.x, exp2(-9.28 * ndotv)) * r.x + r.y; vec2 env = vec2(-1.04, 1.04) * a004 + r.zw; - specular_light *= env.x * f0 + env.y; + specular_light *= env.x * f0 + env.y * clamp(50.0 * f0.g, 0.0, 1.0); #endif } diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl index c92b29b14a..e27c81eaea 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl @@ -199,7 +199,10 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte #endif // LIGHT_ANISOTROPY_USED // F float cLdotH5 = SchlickFresnel(cLdotH); - vec3 F = mix(vec3(cLdotH5), vec3(1.0), f0); + // Calculate Fresnel using specular occlusion term from Filament: + // https://google.github.io/filament/Filament.html#lighting/occlusion/specularocclusion + float f90 = clamp(dot(f0, vec3(50.0 * 0.33)), 0.0, 1.0); + vec3 F = f0 + (f90 - f0) * cLdotH5; vec3 specular_brdf_NL = cNdotL * D * F * G; |