bugfix: Render ground-aligned particles without sorting#2838
bugfix: Render ground-aligned particles without sorting#2838stephanmeesters wants to merge 2 commits into
Conversation
fdcebaf to
45a97a7
Compare
|
@greptileai It should not apply to RenderVolumeParticle as these are layered particles that require sorting |
|
The current PR diff only modifies To guard against that, it would be worth adding a short comment in |
This is very nice. An annoying visual issue. Does it now always fix this issue or does it depend on "random" sorting order? |
| // Enable sorting if the primitives are translucent and alpha testing is not enabled. | ||
| const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled()); | ||
| // However, do not apply sorting for ground-aligned (i.e. non-billboard) particles. | ||
| // This is for performance reasons and because ground-aligned particles do not generally benefit from back-to-front sorting. |
There was a problem hiding this comment.
Can you also mention the visual improvement?
In theory, yes: Particles do not write to the depth buffer (except for ALPHA_TEST particles), which means they do not clip through each other, unless you use a sorting renderer that sorts each triangle by Z and then draws them in order. The sorted particles are drawn last in a frame so all of the ground-aligned particles should now appear behind the sorted particles. The ground-aligned particles are now drawn in the order of how they are in the particle manager list so that should be consistent as well (no flickering etc). (also, ALPHA_TEST particles are never sorted and are always billboarded.) |
|
Ok cool |
|
The bot is complaining about RenderVolumeParticle |
|
Clarified the comment and changed from perf to bugfix as primary contribution, added an info comment to RenderVolumeParticle according to Greptile's suggestion |
A performance gain (about 8%) could be achieved in a busy scene, see animated gif below, by not sorting particles that are "ground-aligned". (tested in release mode, windowed, stats averaged in 60 secs window)
The reasoning is that ground-aligned particles generally do not have much benefit from back to front sorting, as they are effectively on the ground with nothing behind them, and other nearby ground-aligned particles are at about the same height.
In testing this actually appeared to resolve some rendering issues as ground particles would sometimes cut into nearby particles leaving hard edges (see the before image).
sorting-renderer.webm
Todo