From 0cb1e7c6f569f4abe925d66426ef487f7519e162 Mon Sep 17 00:00:00 2001 From: Georg Tomitsch Date: Sat, 6 Jun 2026 10:55:49 +0200 Subject: [PATCH] Fine tune WebGL book indirect lighting --- public/js/webgl-book-lab.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/js/webgl-book-lab.js b/public/js/webgl-book-lab.js index ad15bf6..5d71005 100644 --- a/public/js/webgl-book-lab.js +++ b/public/js/webgl-book-lab.js @@ -552,13 +552,14 @@ function configureBookShadowReceiver(material, strength) { float tableReach = 1.0 - smoothstep(0.0, 0.34, tableDistance); float sideReach = 1.0 - smoothstep(0.02, 0.62, tableDistance); float grazingSide = 1.0 - pow(abs(worldNormal.y), 0.65); + float upFacing = smoothstep(0.24, 0.88, worldNormal.y); float underside = smoothstep(0.16, 0.88, -worldNormal.y); float sideFill = grazingSide * sideReach; - float tableFill = tableReach * (0.22 + underside * 0.24); + float tableFill = tableReach * (0.16 + underside * 0.22) * (1.0 - upFacing * 0.58); float pageFill = smoothstep(0.02, 0.2, tableDistance) * (1.0 - smoothstep(0.24, 0.72, tableDistance)); - vec3 tableWarmth = vec3(0.08, 0.045, 0.024) * tableFill; - vec3 roomWarmth = vec3(0.045, 0.033, 0.024) * sideFill; - vec3 pageWarmth = vec3(0.05, 0.041, 0.029) * pageFill * grazingSide; + vec3 tableWarmth = vec3(0.058, 0.039, 0.026) * tableFill; + vec3 roomWarmth = vec3(0.04, 0.034, 0.028) * sideFill; + vec3 pageWarmth = vec3(0.045, 0.041, 0.034) * pageFill * grazingSide * (1.0 - upFacing * 0.42); vec3 indirect = tableWarmth + roomWarmth + pageWarmth; return albedo * indirect * mix(1.0, 0.72, shadow); }