Particle System Improvements (2018.1)

GPU Mesh Instancing

The Particle System now supports GPU Instancing, when rendering meshes. The Particle System uses Procedural Instancing, which is explained in more detail here: https://docs.unity3d.com/Manual/GPUInstancing.html

Instancing support has been added to the Particle Standard Shaders, and will be enabled by default on all new content. Older content upgraded to Unity 2018.1 can enable GPU Instancing by using the checkbox in the Renderer Module.

It’s also possible to add particle instancing support to your own shaders. Here is a simple example:

Shader "Instanced/ParticleMeshesCustom"

{

    Properties

    {

        _MainTex("Albedo", 2D) = "white" {}

        [Toggle(_FLIPBOOK_BLENDING)] _FlipbookBlending("Flipbook Blending", Int) = 0

    }

    SubShader

    {

        Tags{ "RenderType" = "Opaque" }

        LOD 100

        Pass

        {

            CGPROGRAM

            #pragma vertex vert

            #pragma fragment frag

            #pragma multi_compile __ _FLIPBOOK_BLENDING

            #pragma multi_compile_instancing

            #pragma instancing_options procedural:vertInstancingSetup

            #include "UnityCG.cginc"

            #include "UnityStandardParticleInstancing.cginc"

            struct appdata

            {

                float4 vertex : POSITION;

                fixed4 color : COLOR;

                float2 texcoord : TEXCOORD0;

                UNITY_VERTEX_INPUT_INSTANCE_ID

            };

            struct v2f

            {

                float4 vertex : SV_POSITION;

                fixed4 color : COLOR;

                float2 texcoord : TEXCOORD0;

#ifdef _FLIPBOOK_BLENDING

                float3 texcoord2AndBlend : TEXCOORD1;  

#endif

            };

            sampler2D _MainTex;

            float4 _MainTex_ST;

            fixed4 readTexture(sampler2D tex, v2f IN)

            {

                fixed4 color = tex2D(tex, IN.texcoord);

#ifdef _FLIPBOOK_BLENDING

                fixed4 color2 = tex2D(tex, IN.texcoord2AndBlend.xy);

                color = lerp(color, color2, IN.texcoord2AndBlend.z);

#endif

                return color;

            }

            v2f vert(appdata v)

            {

                v2f o;

                UNITY_SETUP_INSTANCE_ID(v);

                o.color = v.color;

                o.texcoord = v.texcoord;

                vertInstancingColor(o.color);

#ifdef _FLIPBOOK_BLENDING

                vertInstancingUVs(v.texcoord, o.texcoord, o.texcoord2AndBlend);

#else

                vertInstancingUVs(v.texcoord, o.texcoord);

#endif

                o.vertex = UnityObjectToClipPos(v.vertex);

                return o;

            }

            fixed4 frag(v2f i) : SV_Target

            {

                half4 albedo = readTexture(_MainTex, i);

                return i.color * albedo;

            }

            ENDCG

        }

    }

}

Using Instancing enables many more particle meshes to be rendered, with a much smaller CPU performance cost.

Here are 10,000 sphere meshes, using the old non-instanced technique, rendering at 10fps:

Here are 100,000 sphere meshes, using the new instanced technique, rendering at 100fps:

Orbital Particle Velocity

Unity 2018.1 adds some new options to the Velocity over Lifetime module, allowing you to make particles travel relative to a defined center point. By default, the center is aligned with the Transform, but can be overridden within the Module. Particles can be made to travel around the center point, using the Orbital parameters, and away/towards the center point, using the Radial parameters.

Textured Shape Module

All shape types in the Shape module now support a texture. The texture can be used for:

  • Controlling particle colors
  • Controlling particle alphas
  • Discarding particles, based on a threshold and a texture channel of your choice

Sub Emitters

There are 2 new ways to spawn sub emitters in Unity 2018.1. The first is via the Trigger Module, which works in a similar way to how sub emitters are spawned from the Collision Module. Simply choose Trigger as the sub emitter type in the Sub Emitter Module, and then, when conditions are met inside the Trigger Module (e.g. particles have entered the collision volume), the corresponding sub emitters will be triggered.

The second new way to trigger sub emitters is via script. We have added a new script API called TriggerSubEmitter, which can be used to trigger a sub emitter for a single particle, a list of particles, or all particles. In the Sub Emitter Module, you can choose Manual as the spawn type, which tells the Particle System that this emitter will only be triggered via a call in script. It is also possible to use the existing types (eg. Collision, or Death) and add additional triggers for these sub emitters via script.

Legacy Particle System Retirement

The Legacy Particle System continues to be a development burden for each Unity version where it continues to be supported. New engine feature such as VR, and multi-threaded rendering, require time to be spent to ensure continued compatibility as the engine evolves. There are always new engine features, requiring maintenance of the Legacy Particle System code.

This has prompted us to take the next steps in retiring the Legacy Particle System. Therefore, we have decided to remove its Script Bindings in Unity 2018.1.

It has been fully deprecated since Unity 5.4, and our analytics show almost non-existent usage. Our target is to fully remove the Legacy Particle System in Unity 2018.3.

If any of this will affect you, you have some options:

While we can’t make any promises to solve every problem this causes, we will definitely endeavour to listen to your concerns and attempt to mitigate any pain it may cause.

Weighted Tangents (Animation Curves)

The Animation team have added support for weighted tangents, to all curve editing in Unity. This means that you can use this new feature with Particle Systems too! To read more about it, take a look at https://docs.google.com/document/d/1BUV4w7UYShq5aHAoid6mVvlbi2t00jpdnYu9WLQaWdk