23 lines
833 B
Text
23 lines
833 B
Text
shader_type spatial;
|
|
// The scarecrow's fear burst: a flat ring on the ground racing out to the fear radius (the
|
|
// plane is sized to it) with a faint fill behind it, fading as it goes. t runs 0 -> 1 over the
|
|
// burst. Drawn over the scene so raised ground tiles and crops don't hide it.
|
|
render_mode unshaded, cull_disabled, depth_test_disabled, shadows_disabled;
|
|
|
|
uniform float t : hint_range(0.0, 1.0) = 0.0;
|
|
uniform vec4 color : source_color = vec4(0.7, 0.92, 1.0, 1.0);
|
|
|
|
void fragment() {
|
|
vec2 p = UV * 2.0 - 1.0;
|
|
float r = length(p);
|
|
float front = sqrt(t); // fast at first, easing out
|
|
float width = 0.05 + 0.08 * t;
|
|
float fade = 1.0 - t;
|
|
float a = smoothstep(width, 0.0, abs(r - front)) * fade;
|
|
a += step(r, front) * 0.16 * fade;
|
|
if (r > 1.0 || a <= 0.002) {
|
|
discard;
|
|
}
|
|
ALBEDO = color.rgb;
|
|
ALPHA = a * color.a;
|
|
}
|