Search Unity

Resolved HDRP Shader Graph material being incorrectly rendered in front of other materials

Discussion in 'High Definition Render Pipeline' started by lcompton, Jun 8, 2023.

  1. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    I have a game object with a "dissolve" material, implemented via an HDRP Shader Graph, that is being incorrectly rendered in front of other game objects. The dissolve effect occurs when the item spawns or is destroyed. The game object is a capsule presently, which is just a stand in for a more complicated mesh I haven't yet developed.

    The two items which are being rendered behind the capsule are...
    • a laser beam implemented via a Line Renderer with its own Shader Graph based material
    • a spark effect implemented via a VFX Graph, the effect component being attached to an empty which is housed in a prefab
    I've attached two pictures illustrating the problem. Any idea why this happening and what needs to be changed to fix it?

    shader.jpg vfx.jpg
     
  2. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    324
    So the image on the left shows the capsule rendered over the background effects, which seems correct. The image on the right is trickier to make out - it seems the laser is rendered behind the capsule, and the capsule is transparent?
     
  3. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    In both cases, the object is in fact in front of the capsule. The beam image doesn't show that well due to the perspective. The sparks are on a game object on the near side of the capsule.
     
  4. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    Solved.
    • The sparks were showing behind due to the capsule's shader being transparent.
    • The beam problem is due to using the eye vector as the source of the aim raycast. The beam line renderer is passing through the capsule mesh. The fix is to raycast from the weapon muzzle.