summaryrefslogtreecommitdiff
path: root/engine/res/default_shader.slang
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-03 00:10:03 +0200
committerHampusM <hampus@hampusmat.com>2026-08-03 00:10:03 +0200
commitdc677a37fd6f57400fbfb561aa1d5b9002405f8b (patch)
tree0555e73f44986f74db75c2ac6e5edd80051d51fa /engine/res/default_shader.slang
parent15ebe0e8adbbb70994d521b5711875efcff1edc0 (diff)
fix(engine): prevent buggy specular light when material shininess is 0
Diffstat (limited to 'engine/res/default_shader.slang')
-rw-r--r--engine/res/default_shader.slang7
1 files changed, 7 insertions, 0 deletions
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);