started working on fog darkness

This commit is contained in:
2026-01-13 00:16:08 +01:00
parent 82a70aa6a2
commit 89a41397d1
30 changed files with 1613 additions and 386 deletions

View File

@@ -0,0 +1,29 @@
shader_type canvas_item;
uniform float cone_angle : hint_range(0.0, 3.14) = 0.8; // Total width of beam
uniform float direction_degrees : hint_range(0.0, 360.0) = 0.0;
uniform float feather : hint_range(0.0, 1.0) = 0.05;
void fragment() {
// 1. Get the UVs centered at (0.5, 0.5)
vec2 uv = UV - vec2(0.5);
// 2. Calculate the current pixel angle
// atan2 returns values from -PI to PI
float pixel_angle = atan(uv.y, uv.x);
// 3. Convert uniform direction to radians
float target_rad = radians(direction_degrees);
// 4. Calculate difference between angles (wrapped)
float angle_diff = abs(atan(sin(pixel_angle - target_rad), cos(pixel_angle - target_rad)));
// 5. Create the cone mask
// We compare the difference to half the cone angle
float half_cone = cone_angle * 0.5;
float mask = 1.0 - smoothstep(half_cone - feather, half_cone, angle_diff);
// 6. Apply mask to the texture
vec4 tex_color = texture(TEXTURE, UV);
COLOR = vec4(tex_color.rgb, tex_color.a * mask);
}

View File

@@ -0,0 +1 @@
uid://ce7sy7vkt3qr2