diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-10 21:11:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 21:11:48 +0200 |
commit | afb40920fe5a0d6c996d5b055f7b6fd59c84ec07 (patch) | |
tree | 360f59ff44f1031b8a99dc485afa029b9ccb5385 | |
parent | ac1dab5062ff3f56b51ce6585e79af66b1f8c559 (diff) | |
parent | fa962ff27dd0e4249bc882b432fe70d69c4dab2c (diff) |
Merge pull request #51411 from clayjohn/VULKAN-blinn-phong
[4.0] Make Blinn and Phong specular modes take albedo into account
-rw-r--r-- | servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl | 12 |
1 files changed, 5 insertions, 7 deletions
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 7039ea2942..c4fbf3b19d 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl @@ -208,11 +208,10 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte //normalized blinn float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25; - float blinn = pow(cNdotH, shininess) * cNdotL; - blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI)); - float intensity = blinn; + float blinn = pow(cNdotH, shininess); + blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI)); - specular_light += light_color * intensity * attenuation * specular_amount; + specular_light += light_color * attenuation * specular_amount * blinn * albedo * unpackUnorm4x8(orms).w; #elif defined(SPECULAR_PHONG) @@ -220,10 +219,9 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte float cRdotV = clamp(A + dot(R, V), 0.0, 1.0); float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25; float phong = pow(cRdotV, shininess); - phong *= (shininess + 8.0) * (1.0 / (8.0 * M_PI)); - float intensity = (phong) / max(4.0 * cNdotV * cNdotL, 0.75); + phong *= (shininess + 1.0) * (1.0 / (8.0 * M_PI)); - specular_light += light_color * intensity * attenuation * specular_amount; + specular_light += light_color * attenuation * specular_amount * phong * albedo * unpackUnorm4x8(orms).w; #elif defined(SPECULAR_TOON) |