Hit shader

This commit is contained in:
2024-09-15 17:12:18 -07:00
parent 470b853916
commit 4a1fdd94f8
19 changed files with 528 additions and 257 deletions

View File

@@ -0,0 +1,29 @@
shader_type canvas_item;
/**
Color to use for the shock.
*/
uniform vec3 shock_color : source_color = vec3(1.0, 0.0, 0.0);
/**
Initial amplitude of the shock. This will start at this amplitude and
gradually attenuate.
*/
uniform float amplitude = 30.0;
uniform float progress: hint_range(0.0, 1.0) = -1.0;
/**
How fast shold it move side to side, more frequency means it'll move more quickly
side to side.
*/
uniform float frequecy = 10.0;
void vertex() {
float exponent = mod(progress, 3.0);
VERTEX.x += amplitude * exp(-3.0*exponent) * sin(frequecy*exponent);
}
void fragment() {
float exponent = mod(progress, 3.0);
vec3 normal_color = texture(TEXTURE, UV).rgb;
COLOR.rgb = normal_color + shock_color * exp(-3.0*exponent);
}

View File

@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://c0gpeve05njqq"]
[ext_resource type="Shader" path="res://src/vfx/shaders/PixelMelt.gdshader" id="1_uy7cv"]
[resource]
shader = ExtResource("1_uy7cv")
shader_parameter/progress = 0.0
shader_parameter/meltiness = 1.0

View File

@@ -0,0 +1,28 @@
shader_type canvas_item;
// Animate from 0 to 1
uniform float progress: hint_range(0.0, 1.0) = 0.0;
// How jagged each band of melting pixels are
uniform float meltiness: hint_range(0.0, 16.0) = 1.0;
float psuedo_rand(float x) {
return mod(x * 2048103.0 + cos(x * 1912.0), 1.0);
}
void fragment() {
vec2 uv = UV;
// Move pixels near the top faster
uv.y -= progress / UV.y;
// Created jagged edges for each pixel on the x-axis
uv.y -= progress * meltiness * psuedo_rand(UV.x - mod(UV.x, TEXTURE_PIXEL_SIZE.x));
COLOR = texture(TEXTURE, uv);
// "delete" pixels out of range
if (uv.y <= 0.0) {
COLOR.a = 0.0;
}
}

View File

@@ -0,0 +1,10 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://yvt4d1xnftll"]
[ext_resource type="Shader" path="res://src/vfx/shaders/DamageHit.gdshader" id="1_a8e00"]
[resource]
shader = ExtResource("1_a8e00")
shader_parameter/shock_color = Color(1, 0, 0, 1)
shader_parameter/amplitude = 30.0
shader_parameter/progress = 0.0
shader_parameter/frequecy = 10.0