summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2017-10-21 19:52:16 -0400
committerFerenc Arn <tagcup@yahoo.com>2017-10-21 20:25:17 -0400
commit06fcbe009242b2139e98ef60432240734336bf7b (patch)
tree0aa036ecbdbc326356c1df9f3093472d5933b2ca /drivers/gles3
parent50306041e5be9859bd448fe80a52be45694b6688 (diff)
Don't add clearcoat BRDF to specular light as-is.
BRDF needs to be multiplied with N.L, the incoming light and attenuation. Also specular_blob_intensity should affect clearcoat.
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/shaders/scene.glsl10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 0b5b9d1d24..1306054ea7 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1073,7 +1073,7 @@ LIGHT_SHADER_CODE
float cNdotH = max(dot(N,H), 0.0);
float cLdotH = max(dot(L,H), 0.0);
-#if defined(LIGHT_USE_ANISOTROPY)
+# if defined(LIGHT_USE_ANISOTROPY)
float aspect = sqrt(1.0-anisotropy*0.9);
float rx = roughness/aspect;
@@ -1085,11 +1085,11 @@ LIGHT_SHADER_CODE
float D = D_GGX_anisotropic(cNdotH, ax, ay, XdotH, YdotH);
float G = G_GGX_anisotropic_2cos(cNdotL, ax, ay, XdotH, YdotH) * G_GGX_anisotropic_2cos(cNdotV, ax, ay, XdotH, YdotH);
-#else
+# else
float alpha = roughness * roughness;
float D = D_GGX(cNdotH, alpha);
float G = G_GGX_2cos(cNdotL, alpha) * G_GGX_2cos(cNdotV, alpha);
-#endif
+# endif
// F
float F0 = 1.0; // FIXME
float cLdotH5 = SchlickFresnel(cLdotH);
@@ -1115,7 +1115,9 @@ LIGHT_SHADER_CODE
float Gr = G_GGX_2cos(cNdotL, .25) * G_GGX_2cos(cNdotV, .25);
- specular_light += .25*clearcoat*Gr*Fr*Dr;
+ float specular_brdf_NL = 0.25 * clearcoat * Gr * Fr * Dr * cNdotL;
+
+ specular_light += specular_brdf_NL * light_color * specular_blob_intensity * attenuation;
}
#endif
}