Top

PA Particle Field Manual

seed-1_still_tmp

 About

 

PA Particle Field is an alternative particle system for Unity, specifically optimized for looping ambient effects with minimal CPU usage.

PAParticleField combines procedurally generated meshes with a specialized selection of shaders. Particles are positioned within the field bounds, and when a particle reaches one edge of the bounds it reappears on the opposite side. This way a constant number of particles exist at any time. Particles are inherently persistent, they have no “lifetime” or birth/death events, they exist forever only appear to die when they leave the bounds of the field and are recycled, and because of this its possible to emulate an infinite amount of particles simply by parenting the system to the camera.

 

 Getting Started

 

Creating A PA Particle Field in the Editor

To create a field, from the toolbar click “GameObject>Create Other>PA Particle Field”. Alternatively to create a PA Particle Field from scratch, create a new empty GameObject from the toolbar using “GameObject>Create Empty”.

Add a PA Particle Field component to the new GameObject, either by dragging the PAParticleField script from the project window onto the inspector or using the “Add Component” menu.

This will create a PAParticleField with the default settings

Creating a PA Particle Field through Script

There is a helper function to create a PAParticleField in C#

public static PAParticleField PAParticleField.Create(string name)

This will create a new GameObject with the specified name and a PAParticleField component attached.

 Field Properties

 

The Field Properties control the overall appearance and features of the shape of the system, including particle count, simulation space and defining how particles react when they reach the edge of the field.

 

Random Seed

The seed used when generating the random elements of the particle mesh, position, direction, speed, color size and spin speed. Changing this value will change the look of the system, and different seeds may provide nicer distribution of particles. The same seed value will always result in the same particle layout, this can be useful for overlaying particles.

Changing this value causes a complete mesh rebuild.

PLAY

 

Particle Count

The number of particles in the field, the maximum count per field is determined by the particle type, billboard particles are limited to 16250, mesh particles are limited to 65500/(input mesh vertex count) . If more particles are required then create a duplicate PAParticleField with a different seed.

Changing this value causes a partial mesh rebuild.

PLAY

 

Simulation Space

Particles can be simulated in either World, Local or Local with Deltas space. When simulating in world space, when the transform moves the individual particles maintain their world space position and are unaffected by rotation and scale.

In local space the particles move with the transform, the field can be rotated and scaled.

In Local with deltas, when the transform changes position the particles maintain their world space position, but when rotated or scaled the field acts like local space.

Using world space mode it can be made to appear that there are an infinite amount of unseen particles in all directions, with the field acting as a 3D window to view a section of them.

PLAY

 

Field Size

The bounds of the field in units. This determines the area where particles will be visible and the distance from the transform that particles will be recycled. Changing this value noticeably moves the particles, and if modified at runtime probably shouldn’t be changed when the field is on screen.

PLAY

 

Shape

The shape of the field can be set as Cube, Sphere or Cylinder. Particles fade by default when they reach the edge of the field defined by this shape.

PLAY

 

Edge Mode

Defines how particles are handled when they reach the bounds of the field. Particles can fade, scale or both to prevent a sudden disappearance.

PLAY

 

Edge Threshold

Vector3 that indicates how far from the fields edge the particles will be when the Edge Mode begins to affect them. The values should be in the [0-1] range, a value of 1 means the effect starts from the middle of the field. When the Cube shape is used all 3 values are relevant, for the Cylinder just the x and y are used and for a Sphere only the x.

PLAY

 

Rebuild At Runtime

Fields maintain a cache of mesh data which speeds up start up times but can increase scene and build size. By having this option enabled the cache will be cleared, reducing file size and build size but increasing the start up time.

 Exclusion Zones

 

Exclusion Zones allow you to mask out areas in a field, this can be useful to prevent particles passing through your main character, or to completely hide a rain field when the player moves indoors.

To use Exclusion zones first exclusion zones must be enabled on the field, then some exclusion zones must be created, this can be done using GameObject > Create Other > PA Exclusion Zone from the top menu, or creating a new GameObject and add the PAExclusionZone.cs script.

The exclusion zone will show a box gizmo in the scene view representing the zone, this can be scaled, moved and rotated using normal transform controls, when this intersects with the particle field the particles in the intersection will be excluded.

Each field can support 3 exclusion zones at once, meaning that if 4 exclusion zones are intersecting 1 field all at the same time, 1 will not be applied. To pick which three are applied the zones are sorted by ‘importance’ then by distance from the center of the field.

Sometimes sorting from the center of the field is not right for the effect, for example with a large field parented in front of the camera its likely the exclusion zones nearest the camera are more important than those at the center of the field. To sort them by distance from a position other than the center, a transform can be assigned as an anchor override, in this case the camera.

Lastly, because in some cases a particular exclusion zone always wants to be excluded it can be set as ‘important’, when the zones are sorted, ‘important’ zones are sorted first, then unimportant.

 

Use Exclusion Zones

When enabled the field will be affected by up to 3 exclusion zones

PLAY

 

Anchor Override

When exclusion zones are enabled the 3 zones closest to the centre of the field will be used, if a transform is assigned as an override the 3 closest to that transform will be used.

 Global Particle Properties

 

These properties define how the vertices of the particles will be positioned, their speed, size and rotation all contribute to the final particle position.

 

Particle Size

Sets the size of the particles in units, allowing different aspect ratios. For Mesh Particles only the X value is used

PLAY

 

Color

A color applied to all particles, multiplied over any per particle color variation. This is useful for simulating lighting in unlit or fading a field to completely transparency.

PLAY

 

Move Speed

Each particle has a random movement vector, this value indicates how fast all the particles should move along that vector, if particles have varying speed, this value also indicates the maximum speed.

PLAY

 

Speed Mask

Particles have a random 3D direction vector, this property allows this to by scaled or clamped along the x, y and z axis.

PLAY

 

Force

Applies a constant movement in a single direction to all particles, useful for simulating wind, flow or gravity.

PLAY

 

Stretched

When enabled particles orientation will align with the direction they are travelling and their y size will be multiplied by their velocity and the stretch multiplier. Enabling this overrides custom up direction and spin.

Stretch Multiplier

When Stretched is enabled the particles height will be multiplied by this value and the particles velocity. This is currently not applied on mesh particles.

PLAY

 

Spin

When enabled particles will rotate around forward axis of the camera on their pivot.

Spin Speed

The speed at which particles will rotate around their pivot when Spin is enabled.

PLAY

 

Face Direction

By default particles will face the camera, this is normally the desired behavior but sometimes it can be useful to specify the direction the particles should face. This is useful for 2D effects, and effects that depend on a flat surface, for example rain drop ripples on the floor would face up.

Mesh particles face along the Z axis by default.

PLAY

 

Up Direction

By default particles are oriented base on the world up (or in local space mode the transforms up), but this can be overwritten when needed, this is useful for effects like caustics/god rays where the Up Direction is oriented in the direction of the light.

PLAY

 

Soft Particles

Similar to Unity’s own soft particle feature, this effect fades particles to zero as they approach a surface or the camera.

If set to “Near Clip Only” the particles will fade near the camera.

If set to “Near Clip and Camera Depth” the particles will also fade as they approach a surface, to work the camera rendering the particles must render a depth pass, this is enabled by default when using Deferred rendering but in Forward rendering will require a script to change the camera’s depth rendering mode.

See http://docs.unity3d.com/Manual/SL-CameraDepthTexture.html for more information on this topic.

Soft particle values are not applied when a Custom Material is used and should be handled on the material.

 Turbulence

 

Particles can be affected by turbulence, moving them in a non linear way that can add realism to the effect. In the shader, Turbulence is applied after recycling at the bounds and before exclusion zones, this means that when using turbulence its possible for the particle to move outside the regular bounds.

Turbulence is a fairly costly effect and 2 modes are exposed, Simplex2D and Simplex, both modes provide very similar effects but on Simplex2D the z axis movement is reconstructed from the x and y axis movement, making it perform better. On lower end platforms Simplex will fallback to Simplex2D or Sine based depending on available instructions.

When Stretched particles is enabled, the performance hit of turbulence is doubled as the turbulence needs to be recalculated for the previous frame to calculate the direction the particle has moved.

 

Type

 

Sets the type of turbulence to be applied, Simplex2D or Simplex. Both provide similar effects but Simplex2D is faster as it reconstructs the Z axis turbulence from the x and y results.

Note: Currently only Sine based is supported on Unity 4.x

PLAY

 

Frequency

Changes the how radically the turbulence changes from one position to another. Low values mean that particles that are close to each other will have similar amounts of turbulence applied to them so they will appear to move together, high values will make particles act very independent of one another.

Offset Speed

The turbulence can be made to move through the field as well as having the particle move through the turbulence, this value controls the movement of the turbulence in world space.

Combinations of these values can produce many effects, the fish example uses low frequency with a moderate offset speed, and the particles move speed is set to 0. This means that the particles will never move to the edge of the bounds and be recycled, and their movement will be entirely dictated by turbulence. Using a low frequency value all the fish appear to move together in a school.

PLAY

 

Amplitude

Changes how far the particles will move from their pre-turbulence position, a value of 0 would be the equivalent of having no turbulence. This value also determines how far a particle may move outside the bounds.

PLAY

 Per Particle Properties

 

These properties affect values for individual particles, per particle data is encoded into the vertex data and changes will cause a partial mesh rebuild.

 

Color Variation

This is a Gradient value, when the particle mesh is generated particles will sample a random color from the gradient. This allows powerful color customization and weighting, by specifying larger regions of color in the gradient a particle has a greater probability of receiving that color.

Changing this value causes a partial mesh rebuild so should be avoided at runtime if possible.

PLAY

 

Size Variation

Indicates the minimum size a particle will be, as a percentage of the Particle Size. Particles randomly choose a size between this fraction and the main Particle Size. When accessed through scripts this value should be assigned in the [0-1] range.

Changing this value causes a partial mesh rebuild so should be avoided at runtime if possible.

PLAY

 

Speed Variation

Indicates the minimum speed a particle will have, as a percentage of the Move Speed. Particles randomly choose a speed between this fraction and the main Move Speed. When accessed through scripts this value should be assigned in the [0-1] range.

Changing this value causes a partial mesh rebuild so should be avoided at runtime if possible.

 

PLAY

 

Spin Variation

Indicates the minimum spin speed a particle will have, as a percentage of the Spin Speed. When accessed through scripts this value should be assigned in the [0-1] range.

Changing this value causes a partial mesh rebuild so should be avoided at runtime if possible.

PLAY

 Sprite Properties

 

These properties affect the surface of the particle, how its textured and rendered.

 

Material

The material type to be applied to the field, there are several built in shaders including;

  • Transparent
  • Transparent Lit
  • Additive
  • Additive Lit
  • Cutoff
  • Cutoff Lit
  • Mesh Default
  • Mesh Unlit

The material can also be set to Custom, allowing custom materials and shaders to be used for advanced effects. Selecting Custom opens a material slot to drop the desired material. It is assumed that the custom material uses a compatible shader.

Note: Currently all types are shown in the dropdown regardless of particle type, but only shaders prefixed with “Mesh” are compatible with mesh particles, and the mesh shaders are not compatible with billboard particles.

 

Cut Off

When the Blend Mode is set to Cut Off, this value controls the materials Cut Off value.

If a Custom Material is used this has no effect, and should be handled on the material.

 
PLAY

 

Texture Type

The arrangement of the texture can be either Simple, SpriteGrid or AnimatedRows. By default its expected to be a single image, however if SpriteGrid is selected and the Columns and Rows properties are defined, each particle will be randomly assigned a section of the texture. If AnimatedRows is selected each particle will be assigned a row, then at runtime will increment along that row by the Framerate, providing sprite based animation.

 

Texture

The texture applied to the particles.

If a Custom Material is used this has no effect, and should be handled on the material.

 

Pivot Offset

This is the position away from the particles center that the particle will be drawn. This is useful for offsetting rotation and scale.

Examples of unorthodox usage of this is the caustic effect demo, it has its pivot moved to the top of the particle to make the particle scale in a downwards direction, and the snow demo has its pivot offset off the particle completely to add extra cheap turbulence.

Changing this value causes a partial mesh rebuild so should be avoided at runtime if possible (this may change in future versions).

 

Rows

When the Texture Type is SpriteGrid or AnimatedRows, this indicates the number of rows in the texture.

 

Columns

When the Texture Type is SpriteGrid or AnimatedRows, this indicates the number of columns in the texture.

 

Framerate

When the Texture Type is AnimatedRows this value controls the frame rate the animation will play in. The animation will play from left to right when a positive value is used, and right to left when a negative value is used.

23 Comments

  • Just purchased. Great stuff. I am trying to use the PA particle field to replace a standard unity particle emitter that utilizes an additive particle material and noise on the particle behavior. I’ve not been able to get additive to work without creating a new material via PA/ParticleField/Custom/Bokeh. This however appears to disable the turbulence on the particle. Am I missing something? is there a way for me to get both additive and turbulence in PA Particle field?

  • Sean Says

    Is it possible to use this for 3D mesh particles?

  • michel Says

    what is the maximum size I can save my spriteshhet at
    in order for the whole thing to show?

  • Hakazaba Says

    Hi, I want to generate star fields in the shape of galaxies based off a 3d noise generator. (fastnoise or libnoise). I also want to have the ability to change the particle into an object in the scene with its own scripts (3d star that generates planets around itself).

    Is this possible to do with this particle field? I know it isn’t the sort of thing that would be supported by itself, but would i be able to do this with my own scripts in combination? For example, setting the locations of particles of the field based off that noise, then exclude them when we get close while i generate the rest myself.

  • excellency Says

    can i make like the particles is in the tornado? so..be able to do the particles rotate around the field’s center to one direction? it means to make it such as the particle field own spinning.

    • Mark Hogan Says

      Yes PAPF has been used to make tornadoes before, if you set the particle field’s space mode to local you’ll then be able to rotate the field around the Y axis.
      You could get something like a tornado if you also set its shape to cylinder, set the custom up direction to (0,1,0) and make their x size wider than their y size to make it look a bit motion blurred, then rotate the fields transform over time.

  • James Says

    Hi, How do you preview your particles in real time so I can see how the changes I’m making look? The particle field doesn’t animate unless I press play but the changes I make when playing don’t save to the emitter. Am I using it incorrectly?

  • Hayato Kabe Says

    We are developing a game effect using the PAparticle Field.

    Two is a question.
    Is it possible to pause the PAparticleField using a script?
    And,
    Is it possible to stop the PAparticleField using a script?

    We look forward to your reply.
    Thank you.

    • Mark Hogan Says

      Hi Hayato Kabe,

      It’s currently not possible but it would be easy to add, there’s a function in PAParticleField.cs called UpdateAnimationValues, which checks it the application is playing and calls Simulate is it is, adding a second flag for isPlaying or isPaused would work there.

      I’ll add this in an update

  • nrlnd Says

    Aweeeeesome!

    Would need an emition option tho! This would be so awesome if i could get it combined with sonic ethers
    natural bloom. Any possibilities for this?
    http://forum.unity3d.com/threads/se-natural-bloom-dirty-lens.243430/

  • Pan Says

    Can I use this for 2D? I’m using 2D Toolkit orthographic camera and the particles are not showing. Is there a way to set the Sorting Layer/Sorting Order?

    • Mark Hogan Says

      Hi Pan, sorry for not getting back to you sooner.
      It does work with orthographic cameras but there’s a bug with soft particles, I thought I’d fixed it but I must have reverted it inadvertently.
      To make the particles show up in an orthographic camera set the Soft Particles mode to “Near Clip Only” and the Fade Offset to -1

  • I have a question I am making a game for the Gear VR that has many of the same animated character on screen. I am trying to reduce draw calls for these character that have 3 possible animation states walking-hurt-death.
    Would I be able to use this tool’s particle mesh for help?

    • Mark Hogan Says

      It’s a good question but I don’t think Particle Field would be able to help there. It doesn’t support skinned meshes and currently all the mesh particles in a field have to be the same.

  • david plans Says

    hey I’m trying to find the place (maybe in PAParticleField.cs?) where the actual particle generation event happens, so I can trigger an audio synthesis event per particle using Heavy (audio engine)…but I can’t seem to find it. Once I’ve created a particle system in script, how can I access each particle as an event? Is that possible?

    • Mark Hogan Says

      Hi David,
      Sorry currently it’s not possible, since most of the system is shader based particle generation actually doesn’t happen all that often.

      For a bit more explanation, the PAParticleField adds another component called/extending PAMeshGenerator and has a meshIsDirty flag. When the meshIsDirty flag is set the MeshGenerator will be called upon to update the particle mesh, this mostly happens when per particle data changes or the particle count changes.
      After the mesh has been updated the rest of the simulation is handled shader side, on the GPU, the CPU side is unaware of where the particles are or what they’re doing, it just updates and passes on time deltas.

      In order to get particle events the shader simulation code would have to be duplicated in c#, and run on the GPU and CPU simultaneously. I haven’t done this yet because I expect it would impact performance and maintaining the duplicate c# code seems like it would be error prone, but I have seen it done in the Unity Community Ocean which is encouraging. I expect I’ll add it eventually, when I’ve finished adding “one shot” style systems, but it’s not in the near future sorry.

      • david plans Says

        No problem Mark, still a wonderful system, and SO FAST. Is there any chance that that update to the particle mesh is an event I could capture? Basically, I want to add sound to any event in the particle system that would give the viewer the sense that sound is being generated BY the particles.

        • Mark Hogan Says

          There’s no events/delegates fired but you could check PAParticleField.meshIsDirtyMask != 0 in Update from another component, that will tell you if the mesh is about to be updated.
          You might have to set the execution order of your extra component to be ahead of Default Time

  • Tal Says

    Amazing !!! just purchased it on asset store :)

  • Nelson Says

    I’m looking to plot a point cloud. About 1400+ points, but they all have a specific distance and height from the origin. Can this product do that? Thanks

    • Mark Hogan Says

      Hi Nelson, I’m afraid at the moment there’s no methods to let you specify particle positions, it would be a useful feature though!
      One problem though would be how to handle particles placed outside the bounds of the field

Leave a comment

Your email address will not be published.

//