Search Unity

Particle rendering is different when game is built

Discussion in 'Universal Render Pipeline' started by Mufelo, Nov 27, 2020.

  1. Mufelo

    Mufelo

    Joined:
    Feb 17, 2020
    Posts:
    15
    This is... very weird. In editor I get my particle systems running properly _most of the time_. For example, they didn't properly show up when I had animation window open. Now this is ok - most of the time I see what I expect to see.

    However, when I make a windows build - the particle systems do not show up on initial game start. I added a movable camera and when I move REALLY close to where the particle system is supposed to be, it actually gradually becomes visible.

    Now things I've tried so far:
    • Adjusting the clipping planes on the camera
    • Pre-heating the particle system
    • Defaulting all quality settings to high
    • Pausing culling mode
    Probably a bunch of others.

    The weirdest thing is that some particles DO render. My effects consist of multiple nested game objects with many particles so something is different between them but I honestly can't figure out what could cause them to render in Editor and not in Game Mode.

    I'm using the Epic Toon FX asset packs toons for my testing with URP.
     
  2. Mufelo

    Mufelo

    Joined:
    Feb 17, 2020
    Posts:
    15
    As far as I can tell - the particles "fade in" from the edge of this magical Built game barrier. From farther distance it is not rendered at all.
    upload_2020-11-27_4-13-49.png
    upload_2020-11-27_4-14-48.png
    Smaller image is from editor from a distance.
     
  3. Mufelo

    Mufelo

    Joined:
    Feb 17, 2020
    Posts:
    15
    OK, I figured out part of the equation - basically I increased the NEAR clipping plane distance. Now this causes problems elsewhere in my scene because it is clipping the visible view, but now the particles render.

    Why is this behavior different between the editor and the build?
     
    legionair4 likes this.
  4. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    192
    If clipping affects, it might be due to clipping space difference between OpenGL clipping and other GL(DX, Metal, Vulkan). You might want to check if the shader code handles the clipping space in the right fashion.

    Read the clip space coordinates section of the manual: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
     
  5. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    192
    Depending on the GL used, you might be clipping half of the render space away for objects using that particular shader if not handled.

    Sample code for handling:
    Code (CSharp):
    1.                 float4 cVert  = TransformWViewToHClip(vVert);
    2. #if !UNITY_REVERSE_Z
    3.                 cVert.z = 0.5 * (1 + cVert.z);
    4. #endif
     
  6. Mufelo

    Mufelo

    Joined:
    Feb 17, 2020
    Posts:
    15
    I haven't written any custom shaders, these seem like out of the box particle system running on URP. I'm also building for Windows - which is why it is even more puzzling - I would guess it uses DX (and that that'd be what the editor uses) ?
     
  7. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    192