Pixel-burn Shader

A pixel burn shader for 3D spatial.

Shader code
/*
	ピクセル炎上シェーダー by あるる(きのもと 結衣)
	Pixel Burn Shader by Yui Kinomoto @arlez80

	MIT License
*/
shader_type spatial;
render_mode depth_draw_opaque, unshaded, shadows_disabled;

uniform sampler2D noise_tex : hint_white;

uniform float fire_alpha : hint_range( 0.0, 1.0 ) = 1.0;
uniform vec2 fire_speed = vec2( 0.0, 1.0 );
uniform float fire_aperture : hint_range( 0.0, 3.0 ) = 0.22;
uniform vec4 burn_color : hint_color = vec4( 1.0, 0.0, 0.0, 1.0 );

uniform vec2 pixel_size = vec2( 0.01, 0.01 );

uniform sampler2D albedo_tex : hint_albedo;

/*
	noise_texを使わないパターン

float random( vec2 pos )
{ 
	return fract(sin(dot(pos, vec2(12.9898,78.233))) * 43758.5453);
}

float value_noise( vec2 pos )
{
	vec2 p = floor( pos );
	vec2 f = fract( pos );

	float v00 = random( p + vec2( 0.0, 0.0 ) );
	float v10 = random( p + vec2( 1.0, 0.0 ) );
	float v01 = random( p + vec2( 0.0, 1.0 ) );
	float v11 = random( p + vec2( 1.0, 1.0 ) );

	vec2 u = f * f * ( 3.0 - 2.0 * f );

	return mix( mix( v00, v10, u.x ), mix( v01, v11, u.x ), u.y );
}

float procedural_noise_tex( vec2 shifted_uv )
{
	return (
		value_noise( shifted_uv * 0.984864 ) * 20.0
	+	value_noise( shifted_uv * 2.543 ) * 10.0
	+	value_noise( shifted_uv * 9.543543 ) * 8.0
	+	value_noise( shifted_uv * 21.65436 ) * 5.0
	+	value_noise( shifted_uv * 42.0 ) * 2.0
	+	value_noise( shifted_uv * 87.135148 ) * 2.0
	+	value_noise( shifted_uv * 340.66534654 )
	) / 48.0;
}
*/

void fragment( )
{
	vec2 shifted_uv = floor( UV / pixel_size ) * pixel_size + fire_speed * TIME;
	float fire_noise = texture( noise_tex, shifted_uv ).r;
	float noise = UV.y * ( ( ( UV.y + fire_aperture ) * fire_noise - fire_aperture ) * 75.0 );

	vec4 albedo = mix( burn_color, texture( albedo_tex, UV ), clamp( noise, 0.0, 4.0 ) / 4.0 );

	ALPHA = clamp( noise, 0.0, 1.0 ) * fire_alpha * albedo.a;
	ALBEDO = albedo.rgb;
}
Tags
burn, fire, noise, pixel
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from arlez80

Radial Blur Shader

Procedural Cloth Wrinkles Shader

Sobel with Gaussian filter

Related shaders

screen space refraction shader

Mech Gunfire Effect – Smoke Shader

Moebius Shader

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Kolosso
Kolosso
2 years ago

Cool!