2D的烫金字shader。
shader_type canvas_item;
uniform float time_speed : hint_range(0.0, 10.0) = 2.0;
uniform vec4 flame_color1 : source_color = vec4(1.0, 0.4, 0.0, 1.0);
uniform vec4 flame_color2 : source_color = vec4(1.0, 1.0, 0.2, 1.0);
uniform float noise_scale : hint_range(0.1, 10.0) = 3.0;
uniform float distortion_strength : hint_range(0.0, 1.0) = 0.3;
uniform float flame_height : hint_range(0.5, 2.0) = 1.0;
float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
}
float noise(vec2 p){
vec2 ip = floor(p);
vec2 u = fract(p);
u = u*u*(3.0-2.0*u);
float res = mix(
mix(rand(ip), rand(ip+vec2(1.0,0.0)), u.x),
mix(rand(ip+vec2(0.0,1.0)), rand(ip+vec2(1.0,1.0)), u.x),
u.y);
return res;
}
void fragment() {
// 时间循环
float t = mod(TIME * time_speed, 100.0);
vec2 uv = UV;
uv.y += t;
// 噪声扰动
float n = noise(uv * noise_scale);
float distort = n * distortion_strength;
// 火焰颜色渐变
vec4 fire = mix(flame_color1, flame_color2, fract(uv.y * flame_height + distort));
// 顶部渐隐
float fade = smoothstep(1.0, 0.2, fract(uv.y + distort));
// 获取文字纹理的原始颜色
vec4 text_color = texture(TEXTURE, UV);
// 将火焰效果应用于文字颜色
vec3 final_color = text_color.rgb * fire.rgb * fade;
// 保留文字的 Alpha
float alpha = text_color.a;
COLOR = vec4(final_color, alpha);
}