frame-of-mind/src/logic-scenes/card_burner/card_sut.gdshader

52 lines
1.5 KiB
Plaintext

shader_type canvas_item;
render_mode blend_mix;
uniform float fire_progression = 0;
uniform sampler2D flame_noise: repeat_enable;
uniform sampler2D ash_gradoent: repeat_disable;
uniform sampler2D help: hint_screen_texture;
vec3 RNGV3(vec3 p) {
vec3 a = fract(sin(vec3(p.x, p.y, p.z)) * vec3(111.11,333.33,444.44));
a += dot(a, a+33.51);
return fract(vec3(a.x*a.y, a.y*a.z, a.z*a.x)); //outputs a random vec2 between 0 and 1
}
vec4 voronoy(vec3 loc, float scale){
loc = loc*scale;
vec4 output = vec4(0., 0., 0., 10.);
for(float y=-1.; y<=1.; y++){
for(float x=-1.; x<=1.; x++){
for(float z=-1.; z<=1.; z++){
vec3 offs = vec3(x,y,z);
vec3 n = RNGV3(floor(loc)+offs)*2.0-1.0;
vec3 p = offs+sin(n) * .5;
float d = length((fract(loc)-0.5)-p);
if(d<output.q){
vec3 rng = RNGV3(floor(loc)+offs);
output = vec4(rng.x, rng.y, rng.z, d);
}
}
}
}
return output;
}
vec4 smooth_voronoi(vec3 loc, float scale, int steps, float scatter){
vec4 result = vec4(.0);
scatter = scatter/float(steps)/scale;
for (float x = 0.0; x<float(steps); x++) {
for (float y = 0.0; y<float(steps); y++) {
for (float z = 0.0; z<float(steps); z++) {
result += voronoy(loc + vec3(x, y, z) * scatter, scale);
}
}
}
return result / pow(float(steps), 3.);
}
void fragment() {
COLOR *= texture(ash_gradoent, vec2(smooth_voronoi(vec3(UV, .0), 5.0, 2, .2).w * .6 + COLOR.r*3.0 - fire_progression*2.0 +.5));
}