How to disable fog on Particle System shader in Unity
2 min readSep 16, 2021
As we can see here, we use the fog to nicely blend the background of the entire level. Emitting stars under the “You have reached level” are a special effect of Particle System with a custom shader based on Mobile/Particles/Additive.
The solution is very simple. You can make your own shader based on the original with a little change. Here are the steps:
- Download always the newest shaders from the unity site:
http://unity3d.com/download_unity/builtin_shaders.zip - Unpack and find your shader, in our case it was builtin_shaders/DefaultResourcesExtra/Mobile/Mobile-Particle-Add.shader
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)// Simplified Additive Particle shader. Differences from regular Additive Particle one:
// - no Tint color
// - no Smooth particle support
// - no AlphaTest
// - no ColorMaskShader "Mobile/Particles/Additive" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}
- Duplicate this shader, change file name for-example to AdditiveDisabledFog.shader and inside code change to Shader “Mobile/Particles/Additive”. Save it!
- Now open duplicated shader file, try to find Fog { Color (0,0,0,0 } and change it to Fog { Mode Off } like this:
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Simplified Additive Particle shader. Differences from regular Additive Particle one:
// - no Tint color
// - no Smooth particle support
// - no AlphaTest
// - no ColorMask
Shader "Mobile/Particles/AdditiveDisabledFog" {
Properties{
_MainTex("Particle Texture", 2D) = "white" {}
}
Category{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Mode Off }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
SetTexture[_MainTex] {
combine texture * primary
}
}
}
}
}
- Put this shader inside your project, and change on Particle System effect to your customized shader.
If you like this post, just clap :) Thanks a lot!