techkaczynski.dev / code

summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authortech kaczynski <tk@techkaczynski.dev>2026-11-02 16:20:50 +1000
committertech kaczynski <tk@techkaczynski.dev>2026-11-02 16:20:50 +1000
commite5560f69e11051a85c1d54780a59a4fbd83d8ed9 (patch)
treed37903d38226066c993662229b9809d7a46df5a7 /res
parentc7185ab0bace46d63fde4a2af6dbc2f7a4c2dd87 (diff)
fixed foliage shader lighting bugmain
Diffstat (limited to 'res')
-rw-r--r--res/sdr/mdl_foliage.vs11
1 files changed, 11 insertions, 0 deletions
diff --git a/res/sdr/mdl_foliage.vs b/res/sdr/mdl_foliage.vs
index db9d7b6..1198009 100644
--- a/res/sdr/mdl_foliage.vs
+++ b/res/sdr/mdl_foliage.vs
@@ -28,9 +28,20 @@ out vec3 frag_lighting;
void main() {
vec3 world_normal = normalize((matNormal * vec4(vertexNormal, 0.0)).xyz);
+
+ // float sun_diffuse = abs(dot(world_normal, sun_direction));
+ // float moon_diffuse = abs(dot(world_normal, moon_direction));
+
+ // for stronger shading, use 0.3 + 0.7 * abs(...)
+ // float sun_diffuse = 0.5 + 0.5 * abs(dot(world_normal, sun_direction));
+ // float moon_diffuse = 0.5 + 0.5 * abs(dot(world_normal, moon_direction));
float sun_diffuse = abs(dot(world_normal, sun_direction));
float moon_diffuse = abs(dot(world_normal, moon_direction));
+ // hack to fix lighting at midday
+ float midday = smoothstep(0.7, 1.0, sun_direction.y);
+ sun_diffuse = mix(sun_diffuse, 0.65, midday);
+
vec3 ambient_light = ambient_colour * ambient_intensity;
vec3 sun_light = sun_colour * sun_intensity * sun_diffuse;
vec3 moon_light = moon_colour * moon_intensity * moon_diffuse;