This commit is contained in:
2026-09-04 12:38:53 -04:00
parent 3de654d982
commit 7c567ec9dc
59 changed files with 2355 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
shader_type spatial;
render_mode blend_add, cull_disabled, unshaded;
uniform sampler2D dust : source_color;
uniform float dust_speed = 0.03;
uniform vec4 color : source_color;
uniform float intensity = 2.75;
uniform float softness = 3.0;
// Godot 4 explicit texture hints
uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
uniform float proximity_fade_distance = 0.5;
uniform float distance_fade_min = 1.0;
uniform float distance_fade_max = 2.0;
varying vec3 obj_vertex;
void vertex() {
obj_vertex = VERTEX;
}
void fragment() {
// Dust texture sampling using screen coordinates
vec2 dust_uv = vec2(SCREEN_UV.x + dust_speed * TIME, SCREEN_UV.y);
vec4 dust_overlay = texture(dust, dust_uv);
float attenuation = clamp(1.0 + obj_vertex.y / intensity, 0.0, 1.0);
float soft_edge = clamp(pow(dot(NORMAL, normalize(VERTEX)), softness), 0.0, 1.0);
ALBEDO = dust_overlay.rgb * color.rgb * attenuation * soft_edge;
// Proximity Fade calculation in Godot 4
float depth_raw = texture(depth_texture, SCREEN_UV).r;
vec4 ndc = vec4(SCREEN_UV * 2.0 - 1.0, depth_raw, 1.0);
vec4 view_pos = INV_PROJECTION_MATRIX * ndc;
view_pos.xyz /= view_pos.w;
float depth_diff = -VERTEX.z - (-view_pos.z);
float proximity_alpha = clamp(depth_diff / proximity_fade_distance, 0.0, 1.0);
// Distance Fade calculation
float dist_alpha = clamp(smoothstep(distance_fade_min, distance_fade_max, -VERTEX.z), 0.0, 1.0);
ALPHA = proximity_alpha * dist_alpha;
}