nature-sim/leaves.gdshader
Dan Baker f98773237e Implements tree visibility occlusion system.
Adds tree fading based on camera line of sight.
Trees now fade out when they obstruct the player's view,
improving visibility.

Also includes several fixes:
- Fixes tree distribution.
- Adds a see-through shader.
- Adds camera and occlusion scripts.
2025-07-01 10:32:21 +01:00

23 lines
No EOL
744 B
Text

shader_type spatial;
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.1, 1.0);
uniform vec4 variation_color : source_color = vec4(0.4, 0.8, 0.2, 1.0);
uniform float gradient_height : hint_range(0.1, 5.0) = 2.0;
uniform float gradient_offset : hint_range(-2.0, 2.0) = 0.0;
varying vec3 world_position;
void vertex() {
world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
}
void fragment() {
// Use world Y position instead of UV
float gradient_factor = (world_position.y + gradient_offset) / gradient_height;
gradient_factor = clamp(gradient_factor, 0.0, 1.0);
vec3 final_color = mix(base_color.rgb, variation_color.rgb, gradient_factor);
ALBEDO = final_color;
ROUGHNESS = 0.8;
METALLIC = 0.0;
}