mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-11 12:32:54 +08:00
feat: 添加炸弹效果和着色器,创建新的Bomb效果和相关资源
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform float explosion_radius : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform float explosion_intensity : hint_range(0.0, 2.0) = 1.0;
|
||||
uniform vec4 explosion_color : source_color = vec4(1.0, 0.5, 0.0, 1.0);
|
||||
uniform float time_scale = 1.0;
|
||||
|
||||
void fragment() {
|
||||
// 计算当前像素到中心的距离
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
float dist = distance(UV, center);
|
||||
|
||||
// 使用TIME创建随时间变化的爆炸效果
|
||||
float time = TIME * time_scale;
|
||||
float explosion = smoothstep(explosion_radius, explosion_radius - 0.2, dist) * explosion_intensity;
|
||||
|
||||
// 添加一些噪声使爆炸看起来更自然
|
||||
float noise = sin(dist * 20.0 - time * 5.0) * 0.1;
|
||||
explosion += noise;
|
||||
|
||||
// 计算最终颜色,混合原始纹理和爆炸效果
|
||||
vec4 original_color = texture(TEXTURE, UV);
|
||||
vec4 final_color = mix(original_color, explosion_color, explosion);
|
||||
|
||||
// 添加一些发光效果
|
||||
float glow = exp(-dist * 5.0) * explosion_intensity;
|
||||
final_color.rgb += glow * explosion_color.rgb;
|
||||
final_color.a;
|
||||
// 输出最终颜色
|
||||
COLOR = final_color;
|
||||
}
|
||||
@@ -3,10 +3,14 @@ uniform vec4 color: source_color;
|
||||
uniform float laser_width: hint_range(0.01, 1.0) = 0;
|
||||
uniform float soft_edge: hint_range(0.0, 0.5) = 0.5;
|
||||
void fragment() {
|
||||
float dist = abs(UV.x - 0.5);
|
||||
float textureWidth=float(textureSize(TEXTURE,0).x);
|
||||
float textureHeight=float(textureSize(TEXTURE,0).y);
|
||||
float radius=textureHeight/2.0;
|
||||
float radiusU=radius*TEXTURE_PIXEL_SIZE;
|
||||
float dist = distance(vec2(0.5,clamp(UV.y,radiusU,1.0-radiusU)),UV);
|
||||
float core = 1.0 - smoothstep(0.0, laser_width, dist);
|
||||
float edge = 1.0 - smoothstep(laser_width, laser_width + soft_edge, dist);
|
||||
float alpha = max(core, edge);
|
||||
float edge=1.0 - smoothstep(laser_width, laser_width + soft_edge, dist);
|
||||
float alpha = max(core, edge);
|
||||
COLOR = color;
|
||||
COLOR.a = alpha;
|
||||
}
|
||||
Reference in New Issue
Block a user