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;
}