nature-sim/leaves.gdshader
Dan Baker 3959333534 Adds bushes and flowers to ground tiles
Implements bush and flower spawning on ground tiles based on vegetation density.
Adds new assets for bushes and flowers, and introduces multi-mesh rendering for optimized performance.
Introduces seasonal color variations for vegetation using a shader for bushes and materials for flowers and grass.
Refactors material application into a MaterialManager to handle material assignments over multiple frames.
Moves ground tile scripts into a subfolder.
Adds floating particles to test scene.
2025-06-29 10:58:18 +01:00

23 lines
No EOL
752 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;
}