Fire Shader
Here’s how to create a Fire Shader.
As always, you can also find below the HLSL Shader and, if you’re supporting me on Patreon, the download link for the Unity Package.
HLSL
//@febucci, https://www.febucci.com/tutorials/
//Support my work here: https://www.patreon.com/febucci
Shader "Fire"
{
Properties
{
_NoiseTex("Noise Texture", 2D) = "white" {}
_GradientTex("Gradient Texture", 2D) = "white" {}
_BrighterCol("Brighter Color", Color) = (1,1,1,1)
_MiddleCol("Middle Color", Color) = (.7,.7,.7,1)
_DarkerCol("Darker Color", Color) = (.4,.4,.4,1)
}
SubShader
{
//The shader is transparent
Tags
{
"RenderType" = "Transparent"
}
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityShaderVariables.cginc" //to use _Time
sampler2D _NoiseTex;
sampler2D _GradientTex;
float4 _BrighterCol;
float4 _MiddleCol;
float4 _DarkerCol;
//Input for the vertex
struct appdata {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
};
//Output for the fragment
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(appdata v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
float4 frag(v2f IN) : SV_Target {
float noiseValue = tex2D(_NoiseTex, IN.uv - float2(0, _Time.x)).x; //fire with scrolling
float gradientValue = tex2D(_GradientTex, IN.uv).x;
float step1 = step(noiseValue, gradientValue);
float step2 = step(noiseValue, gradientValue-0.2);
float step3 = step(noiseValue, gradientValue-0.4);
//The entire fire color
float4 c = float4
(
//Calculates where to place the darker color instead of the brighter one
lerp
(
_BrighterCol.rgb,
_DarkerCol.rgb,
step1 - step2 //Corresponds to "L1" in my GIF
),
step1 //This is the alpha of our fire, which is the "outer" color, i.e. the step1
);
c.rgb = lerp //Calculates where to place the middle color
(
c.rgb,
_MiddleCol.rgb,
step2 - step3 //Corresponds to "L2" in my GIF
);
return c;
}
ENDCG
}
}
}
Amplify Shader

Thanks for reading! ❤️
Let us know what you think! We're a small team and we are loving what we do, so any feedback is appreciated ❤️ You can also consider joining the newsletter (either weekly or monthly, we care deeply about it) and never miss our new posts. Cheers!
✦ Join the newsletterMore Posts
Text Animator for Unity 3.0 is out! UI Toolkit, new animations and more
Bringing UI Toolkit Support, a new way to animate, better documentation and much much more!
I'm giving a talk, a panel and a livestream at Unite 2025!
Meet me at Unite 2025 talking about tools, showcasing Text Animator 3.0 and more! Looking forward to seeing you!
Easy Outline for Godot is out!
How to create an outline in Godot? With Easy Outline you can add outline to all objects in your game!
Minecraft is removing Code Obfuscation in Java!
You will be able to learn how Minecraft is built piece by piece, and mod the game even more easily.
How to make a Triplanar Shader in Godot
We made a simple terrain shader for Godot, which lets you apply different textures on based slopes and more. Have fun!
Text Animator for Godot is Out in Early Access!
Text Animator for Godot is out now in Early Access! Start bringing your texts to life in a few clicks and help us shape the future of this tool in Godot! Cheers!
Comments