60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
shader_type canvas_item;
|
|
|
|
uniform float fire_progression = 0;
|
|
uniform sampler2D disp_noise: repeat_enable;
|
|
uniform sampler2D crackle_noise: repeat_enable;
|
|
uniform sampler2D ash_gradient: repeat_disable;
|
|
|
|
|
|
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.w *= max(.0, 1.0-length(UV-0.5)*2.0);
|
|
vec2 card_uv = fract(UV*vec2(2, 3));
|
|
float burn_gradient = max(0, length(vec2(.7, .2) - card_uv) * 3.0) + sin(TIME*2.0)*.1 + sin(TIME*3.5)*.02;
|
|
float burn_texture = texture(crackle_noise, UV + (texture(disp_noise, UV).xy-.5)*fire_progression*0.3).r;
|
|
COLOR.w *= clamp(texture(crackle_noise, UV + (texture(disp_noise, UV).xy-.5)*fire_progression*0.2).r*3.0-(fire_progression+burn_gradient*.3-1.2)*3.0, .0, 1.0);
|
|
vec4 sut_texture = texture(ash_gradient, vec2(smooth_voronoi(vec3(UV, .0), 12.0, 2, .2).w * .6 - burn_gradient - fire_progression*2.0 + COLOR.w * 3.0));
|
|
COLOR = mix(COLOR.rgba, vec4(COLOR.rgb*sut_texture.rgb, COLOR.w), sut_texture.w);
|
|
//COLOR.rg = card_uv;
|
|
}
|