Skip to content

Sorting is difficult / impossible to control for particles with transparency #43

@mbalfour-amzn

Description

@mbalfour-amzn

Short version:
In the MultiplayerSample project, we've run into multiple particle sorting issues, and there doesn't seem to be a way to work around or fix it. This is a request to at a minimum provide a way to "unbatch" particle emitters for specific emitters to make it possible to fix sorting issues when problems arise.

Long version:
Atom sorts transparent draw calls first by sort key, and then by depth. By default, everything uses a sort key of 0. PopcornFX is also currently hard-coding a sort key of 0 in CPopcornFXFeatureProcessor::Render(). In the case of MultiplayerSample, we need depth sorting since the particles appear in a level that has translucent walls everywhere, so this is OK. It would also be nice if sort key controls were exposed instead of hard-coded, but that wouldn't help for this situation anyways.

The problems show up due to particle batching. The particle effects we're using have multiple layers to them, and each layer has different-sized particles. For simplicity, let's just say there are 2 layers, one with a 1 meter particle and one with a 5 meter particle. We also reuse the effects multiple times around the level, so the same effect can draw hundreds of meters apart. These two factors are affecting the sorting in negative ways:

  1. The 2 layers of the particle effect draw in inconsistent orders relative to each other. Each layer is batched separately and contains a bounding box affected by the size of the particles, so even though both layers start with the same emitter centers, the bounding boxes become different sizes due to the size of the particles, which means that the centers can have different depths to them. This will change which layer sorts in front of the other layer when drawing, because even if the emitter centers create a 100 m bounding box, the bounding box of the two layers will be 101 m and 105 m, so they will have slightly different center points that will sort differently depending on camera location. The following video demonstrates the problem where the light blue swirl briefly sorts in front of the dark blue center depending on the overall locations of multiple particle systems relative to the camera.
Editor_AOtsrn9TFR.mp4
  1. A batched set of particle effects only has one depth value that's used to sort it vs the world. Consequently, all of the effects need to appear on the same side of a second transparent item in the world or else they will sort incorrectly. The following images demonstrate the problem. There's no way to make the two different effects sort with different depth values so that one appears in front of the window and the other appears behind it.

image
image
image

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions