Pixelated burn

Heavily inspired by these two shaders
https://godotshaders.com/shader/burn-sprite/
https://godotshaders.com/shader/2d-burn-dissolve-from-point-v-1-0/

I needed something like this but which had both effects (from one point and multiple colors) and also was pixelated, so that it could fit better with pixel art.

Shader code
shader_type canvas_item;

uniform vec2 position;
uniform float radius;
uniform float borderWidth = 0.2;
uniform float burnMult = 0.34;
uniform sampler2D noiseTexture;
uniform vec4 burnColor : source_color;
uniform float pixel_size = 0.004;
uniform float blend_steps = 8.5; // lower number = more saturated

uniform sampler2D colorCurve;


void fragment() {
    vec2 snapped_uv = floor(UV / pixel_size) * pixel_size;

    float dist = length(position - snapped_uv) + (texture(noiseTexture, snapped_uv).b) * burnMult;
    float mask = clamp((dist - (radius - borderWidth)) / (2.0 * borderWidth), 0.0, 1.0);
    mask = 1.0 - mask;
    mask = floor(mask * blend_steps) / blend_steps;
	
    vec4 curve_value = texture(colorCurve, vec2(mask, 0.0));
    
    float blendMask = pow(mask, 0.1); 
    COLOR.rgb = mix(COLOR.rgb, curve_value.rgb, blendMask);
    
	COLOR.a *= min(COLOR.a,1.0-(float(dist<radius)));
}
Tags
burn, disolve, pixel
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

2D Burn/dissolve with direction (V 1.0)

燃烧/burn 2d

2D Burn/dissolve from point (V 1.0)

guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
shadecore_dev
15 days ago

Very nice effect. Thank you for sharing!