16 lines
571 B
Plaintext
16 lines
571 B
Plaintext
shader_type spatial;
|
|
render_mode blend_mix, depth_draw_always, cull_disabled;
|
|
|
|
uniform sampler2D texture_albedo : source_color;
|
|
uniform float fade_distance : hint_range(0.0, 10) = 1.0;
|
|
uniform vec4 fade_color : source_color = vec4(0.2, 0.5, 1.0, 0.4);
|
|
uniform float object_dist_to_camera = 10.0; // updated from script every frame
|
|
|
|
void fragment() {
|
|
vec4 tex_color = texture(texture_albedo, UV);
|
|
|
|
float t = smoothstep(0.0, fade_distance, object_dist_to_camera);
|
|
|
|
ALBEDO = mix(fade_color.rgb, tex_color.rgb, t);
|
|
ALPHA = mix(fade_color.a, tex_color.a, t);
|
|
} |