Lit Smoke/Fire particles in Unity (Need some help)

Hi, recently, I was very interested in creating lit smoke particles in Unity. But I don’t fully understand how exactly it can be done. All particles are billboard and always face the camera. So how they can be lit from a back side for example and also use normal maps like explosions from this video -

Found two good tutorials:

http://bbs.cgwell.com/thread-39592-1-1.html

But it’s not fully lit. I want particles to receive ambient/directional lights and if it’s possible, get information from light probes too. Or maybe it’s not worth it?

ok im very used to writing my own shaders and doing the lighting myself, but i think that can seem like a daunting task. is there a reason the standard shader wont work for you?

Well, I want to create sort of a fake volumetric effect with particles only, while preserving billboard rendering.

Here are some references from UE4:

https://docs.unrealengine.com/latest/images/Engine/Rendering/Materials/MaterialProperties/PerPixNonDirectional.jpg

https://docs.unrealengine.com/latest/images/Engine/Rendering/Overview/self_shadow_1.jpg

Believe that used some kind of opacity shadow mapping right?

Ue4 is in fact using opacity shadow mapping for the main light source. This is not easily achievable in shader Forge. I guess you could do it but you would have to create some custom buffers which involves scripting.

Yeah, it’s not really fair to call that “fake” volumetrics since the shadowing technique is actually a true volumetric effect. There are assets on the Unity asset store that add similar functionality, but it’s not as well integrated into the rest of the lighting systems.

Unity’s lighting system by default is also not great for handling multiple lights on transparent objects with out some tricks. There’s one asset on the store that does some nice stuff to try and fake volumetric lighting on particles to a degree, as well as support dynamic lighting.

Curiously the author of that asset started down the road of implementing something like the shadowing technique Unreal uses before eventually abandoning it.

Hello, for unity try this shader with main texture and normal map texture:

Shader “Particles/CustomLitParticlesSurface” {
Properties {
_Color (“Color”, Color) = (1,1,1,1)
_MainTex (“Albedo (RGB)”, 2D) = “white” {}
_BumpTex(“Normal Map (RGB)”, 2D) = “bump” {}
_BumpScale (“Scale”, Float) = 1.0
_Cutoff(“Cutoff” , Range(0,1)) = .4
}
SubShader {
Tags{ “Queue” = “AlphaTest” “RenderType” = “TransparentCutout” }
//Tags{ “Queue” = “Geometry” }
LOD 200
ZWrite Off
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert vertex:vert alpha:fade AlphaTest:_Cutoff
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpTex;
float4 _BumpTex_ST;
half _BumpScale;
struct Input {
float2 uv_MainTex;
//float3 normal;
//float4 lpos;
fixed4 vcolor;
};
fixed4 _Color;
void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
//o.normal = v.normal;
//o.lpos = v.vertex;
o.vcolor = v.color;
}
inline fixed3 CombineNormalMaps(fixed3 base, fixed3 detail) {
base += fixed3(0, 0, 1);
detail = fixed3(-1, -1, 1);
return base * dot(base, detail) / base.z - detail;
}
void surf (Input IN, inout SurfaceOutput o) {
float4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color * IN.vcolor;
//--------------------------------------------------------------
// o.Normal = UnpackNormal(tex2D(_BumpTex, IN.uv_MainTex
_BumpTex_ST.xy)); —> Remplacé par les 2 lignes suivantes
half4 normalMap = tex2D(_BumpTex, IN.uv_MainTex*_BumpTex_ST.xy);
o.Normal = UnpackScaleNormal(normalMap, _BumpScale);
//--------------------------------------------------------------
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
//Fallback “Diffuse”
Fallback “Transparent/Cutout/VertexLit”
}

3 Likes

A little curious to see alpha test used with ZWrite Off. Also note this will only work with Unity 5.5 or newer as 5.4 didn’t support tangents on particles.

It is nice to see reoriented normal mapping in there, even if it isn’t being used…

I use it in a 2D game. Remove the ZWrite Off line for 3D scene.

1 Like

You can also try the pre-release official Standard Particle shader.

@richardk posted about it here: New Unity Built-in Particle Shader

1 Like