From 6f07643431967406dd903ce2c0703b3c59b0dc7c Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sun, 11 Aug 2024 13:33:20 +0200 Subject: [PATCH] libgarbage: clamp lighting to 0..1 --- Assets/raymarched/Raymarching.unity | 2 +- Assets/raymarched/lib/libgarbage.cginc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/raymarched/Raymarching.unity b/Assets/raymarched/Raymarching.unity index 47b0326..86f1e32 100644 --- a/Assets/raymarched/Raymarching.unity +++ b/Assets/raymarched/Raymarching.unity @@ -1007,7 +1007,7 @@ MonoBehaviour: m_EditorClassIdentifier: type: 3 objectId: dfb56a47-2b0b-4814-a4b0-950b5054b182 - randomNum: 27659988 + randomNum: 95618923 unityVersion: 2021.3.41f1 cckVersion: 3.10:132 --- !u!114 &649783671 diff --git a/Assets/raymarched/lib/libgarbage.cginc b/Assets/raymarched/lib/libgarbage.cginc index d5f2f55..b0fddc1 100644 --- a/Assets/raymarched/lib/libgarbage.cginc +++ b/Assets/raymarched/lib/libgarbage.cginc @@ -181,7 +181,7 @@ FragOut frag (V2F i) { first_hit = ray.hit_pos; inside_shape = ray.steps == 0; } - float3 light = LIGHT_FN(ray); + float3 light = clamp(LIGHT_FN(ray), 0, 1); col_acc *= ray.mat.col * lerp(light, 1, ray.mat.gloss); ray_num++; if (ray.missed || ray.mat.gloss < 0.01) { @@ -291,7 +291,7 @@ float3 default_lighting(Ray ray) { return SKY_FN(ray.dir); float3 light = lSun(ray.normal, sun_dir); light *= lShadow(ray.hit_pos + ray.normal * SURF_DIST, sun_dir, 50); - light += lSky(ray.normal); + light += lSky(ray.normal); return light; }