Skip to content

Commit bfb379b

Browse files
committed
Merge pull request godotengine#108378 from Mingxi-Z/fix/clearcoat-nan-issue
Fix division by zero in clearcoat specular BRDF
2 parents afd16dd + 2096e4c commit bfb379b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/gles3/shaders/scene.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, bool is_di
14481448
float cLdotH5 = SchlickFresnel(cLdotH);
14491449
#endif
14501450
float Dr = D_GGX(ccNdotH, mix(0.001, 0.1, clearcoat_roughness));
1451-
float Gr = 0.25 / (cLdotH * cLdotH);
1451+
float Gr = 0.25 / (cLdotH * cLdotH + 1e-4);
14521452
float Fr = mix(.04, 1.0, cLdotH5);
14531453
float clearcoat_specular_brdf_NL = clearcoat * Gr * Fr * Dr * cNdotL;
14541454

servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void light_compute(hvec3 N, hvec3 L, hvec3 V, half A, hvec3 light_color, bool is
167167
half cLdotH5 = SchlickFresnel(cLdotH);
168168

169169
half Dr = D_GGX(ccNdotH, half(mix(half(0.001), half(0.1), clearcoat_roughness)), vertex_normal, H);
170-
half Gr = half(0.25) / (cLdotH * cLdotH);
170+
half Gr = half(0.25) / (cLdotH * cLdotH + half(1e-4));
171171
half Fr = mix(half(0.04), half(1.0), cLdotH5);
172172
half clearcoat_specular_brdf_NL = clearcoat * Gr * Fr * Dr * cNdotL;
173173

0 commit comments

Comments
 (0)