From 89dc791510d3ee8ec45d7de005960d1bb9c1a766 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 10 Apr 2026 23:25:35 +0200 Subject: [PATCH] tune(shaders): more dramatic Phase 3a lighting contrast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original Phase 3a constants had SUN_DIR=(0.4,0.3,0.8) — heavily vertical, so roofs and ground both landed near peak brightness and only walls dropped. Combined with AMBIENT=0.4/DIFFUSE=0.6 the lit-vs- shadow contrast was ~2.2x, which was real but hard to read through textures. User feedback: "Ligtning looks the same I think." Diagnosed with a temporary grayscale-lighting fragment output — walls on different sides of the same building did show different brightness, confirming the Phase 3a/3b pipeline is wired correctly end-to-end and the issue was purely perceptual contrast. Retuned: SUN_DIR=(0.5,0.4,0.6) (more oblique), AMBIENT=0.25, DIFFUSE=0.75. Contrast ratio now ~3.3x. User-verified visually. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/AcDream.App/Rendering/Shaders/mesh.frag | 10 +++++++--- src/AcDream.App/Rendering/Shaders/terrain.frag | 14 ++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/AcDream.App/Rendering/Shaders/mesh.frag b/src/AcDream.App/Rendering/Shaders/mesh.frag index 28503bb..42d2d96 100644 --- a/src/AcDream.App/Rendering/Shaders/mesh.frag +++ b/src/AcDream.App/Rendering/Shaders/mesh.frag @@ -9,9 +9,13 @@ uniform sampler2D uDiffuse; // gives scenery and building faces enough differentiation to read as 3D instead // of looking like paper cutouts. Hardcoded for now; a later phase can route // light parameters through uniforms driven by the game's time-of-day. -const vec3 SUN_DIR = normalize(vec3(0.4, 0.3, 0.8)); -const float AMBIENT = 0.4; -const float DIFFUSE = 0.6; +// Sun direction tuned after Phase 3a verification: (0.4,0.3,0.8) was too +// vertical — roofs and ground both landed near peak brightness and only +// walls dropped, so the contrast was hard to read through textures. More +// oblique + lower ambient + higher diffuse = contrast ratio ~3.3x. +const vec3 SUN_DIR = normalize(vec3(0.5, 0.4, 0.6)); +const float AMBIENT = 0.25; +const float DIFFUSE = 0.75; void main() { vec4 sampled = texture(uDiffuse, vTex); diff --git a/src/AcDream.App/Rendering/Shaders/terrain.frag b/src/AcDream.App/Rendering/Shaders/terrain.frag index f3ebbe4..76a8db0 100644 --- a/src/AcDream.App/Rendering/Shaders/terrain.frag +++ b/src/AcDream.App/Rendering/Shaders/terrain.frag @@ -6,14 +6,12 @@ out vec4 fragColor; uniform sampler2DArray uAtlas; -// Phase 3a: shared lighting model with mesh.frag. Terrain normals are currently -// flat UnitZ (Phase 2b set this when building LandblockMesh vertices) so every -// terrain fragment gets the same ndotl contribution — terrain will look a bit -// flatter than hill-shaded terrain, which is a Phase 3b concern (compute -// per-vertex normals from the 9x9 heightmap to get relief lighting). -const vec3 SUN_DIR = normalize(vec3(0.4, 0.3, 0.8)); -const float AMBIENT = 0.4; -const float DIFFUSE = 0.6; +// Shared lighting model with mesh.frag — must stay in sync. Phase 3b gave +// terrain real per-vertex normals via central differences on the heightmap, +// so hills catch and shade the sun just like static meshes do. +const vec3 SUN_DIR = normalize(vec3(0.5, 0.4, 0.6)); +const float AMBIENT = 0.25; +const float DIFFUSE = 0.75; void main() { vec4 sampled = texture(uAtlas, vec3(vTex, float(vLayer)));