-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfire.gdshader
More file actions
28 lines (22 loc) · 1.06 KB
/
fire.gdshader
File metadata and controls
28 lines (22 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D noise_texture : hint_default_white, filter_nearest, repeat_enable;
uniform vec4 base_color : source_color = vec4(1.0, 0.75, 0.3, 1.0);
uniform vec4 edge_color : source_color = vec4(1.0, 0.1, 0.0, 1.0);
uniform float fire_alpha : hint_range(0.0, 1.0) = 1.0;
uniform float fire_filter : hint_range(0.0, 3.0) = 0.2;
uniform float fire_power : hint_range(1.0, 20.0) = 10.0;
uniform vec2 fire_speed = vec2(0.0, 1.0);
uniform float fire_offset : hint_range(-1.0, 1.0) = 0.2; // New
uniform sampler2D mask_texture : hint_default_white;
void fragment()
{
vec2 uv = UV + TIME * fire_speed;
float fire_noise = texture(noise_texture, uv).r;
float mask = texture(mask_texture, uv).r;
// Apply vertical offset to shift fire upward
float y_offset_uv = clamp(UV.y + fire_offset, 0.0, 1.0);
float noise = (fire_noise * (fire_filter + y_offset_uv) - fire_filter) * y_offset_uv * fire_power * mask;
vec4 fire_color = mix(edge_color, base_color, noise);
COLOR = vec4(fire_color.rgb * mask, clamp(noise, 0.0, 1.0) * fire_alpha);
}