diff options
| author | tech kaczynski <tk@techkaczynski.dev> | 2026-11-04 05:56:35 +1000 |
|---|---|---|
| committer | tech kaczynski <tk@techkaczynski.dev> | 2026-11-04 05:56:35 +1000 |
| commit | ea84213ece95e3ef8ff7f0095cee73ee6bdd0f9a (patch) | |
| tree | 32a502e72438ba0c6b6fa00dbd9dbdf3603fe7e3 /res/sdr/mdl_foliage.vs | |
| parent | e5560f69e11051a85c1d54780a59a4fbd83d8ed9 (diff) | |
added convex hull and trimesh colliders. Fixed physics edit mode bugs. Added debug drawing for all supported collision types.
Diffstat (limited to 'res/sdr/mdl_foliage.vs')
| -rw-r--r-- | res/sdr/mdl_foliage.vs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/res/sdr/mdl_foliage.vs b/res/sdr/mdl_foliage.vs index 1198009..366290a 100644 --- a/res/sdr/mdl_foliage.vs +++ b/res/sdr/mdl_foliage.vs @@ -27,20 +27,21 @@ out vec4 frag_colour; out vec3 frag_lighting; void main() { - vec3 world_normal = normalize((matNormal * vec4(vertexNormal, 0.0)).xyz); + vec3 canopy_center = vec3(0.0, 4.0, 0.0); + vec3 canopy_normal = vertexNormal; + vec3 offset = vertexPosition - canopy_center; - // float sun_diffuse = abs(dot(world_normal, sun_direction)); - // float moon_diffuse = abs(dot(world_normal, moon_direction)); + if (dot(offset, offset) > 0.0001) { + canopy_normal = normalize(offset); + } - // 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)); + vec3 world_normal = normalize((matNormal * vec4(canopy_normal, 0.0)).xyz); - // hack to fix lighting at midday - float midday = smoothstep(0.7, 1.0, sun_direction.y); - sun_diffuse = mix(sun_diffuse, 0.65, midday); + float sun_facing = dot(world_normal, sun_direction); + float moon_facing = dot(world_normal, moon_direction); + + float sun_diffuse = max(sun_facing, 0.0) + 0.1 * max(-sun_facing, 0.0); + float moon_diffuse = max(moon_facing, 0.0) + 0.1 * max(-moon_facing, 0.0); vec3 ambient_light = ambient_colour * ambient_intensity; vec3 sun_light = sun_colour * sun_intensity * sun_diffuse; |
