From dc677a37fd6f57400fbfb561aa1d5b9002405f8b Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 3 Aug 2026 00:10:03 +0200 Subject: fix(engine): prevent buggy specular light when material shininess is 0 --- engine/res/default_shader.slang | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engine/res') diff --git a/engine/res/default_shader.slang b/engine/res/default_shader.slang index e42b83a..1f79dbe 100644 --- a/engine/res/default_shader.slang +++ b/engine/res/default_shader.slang @@ -164,6 +164,13 @@ struct BlinnPhongLighting in float2 texture_coords ) { + // The result of the below pow is undefined if both arguments is 0. This stops + // that problem. This prevents buggy specular light when shininess is 0. + if (this.material.shininess == 0.0) { + return light_phong.specular * + (specular_map.Sample(texture_coords).xyz * this.material.specular); + } + float3 view_direction = normalize(this.view_pos - frag_pos); float3 halfway_direction = normalize(light_dir + view_direction); -- cgit v1.2.3-18-g5258