Search Unity

How to change a Projector rendering queue to prevent from overriding ImageEffects

Discussion in 'Shaders' started by stephero, Nov 25, 2016.

  1. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi guys,

    Is there a way to change the rendering queue (Opaque, Transparent, or whatever...) of a Projector?
    I tried to change both Queue and RenderType tags of my projector shader, but the Projector rendering always happens during the Render.TransparentGeometry queue.
    Screenshot_18.jpg

    My problem is that I would like to apply ImageEffects such as Edge Detection and SSAO AFTER my projectors.
    These kind of ImageEffects are drawn between the Opaque and Transparent queues (using [ImageEffectOpaque]). But since I find no way to change the Projector rendering queue, my projectors are always rendered AFTER my ImageEffects, and so they override my edges and SSAO.


    Here you can see that my Projector projects a green color, but it overrides my blacks edges and my SSAO:
    Screenshot_20.jpg

    Thanks
     
  2. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi,
    I continued my experimentations and it's really weird:
    if I put the queue for my projector at "Background", it works, the projector is rendered in the opaque queue and I can see my ImageEffects:
    Untitled-1.jpg

    But once I see a Transparent object in camera frustum, the projector is also rendered in the Transparent queue (next to my Transparent object), and so it overrides my ImageEffects:
    Untitled-2.jpg


    I tried some stuff using the standard Projectors materials and shaders Unity provides in the standard Effects package, and I have the same issue: try to put a ShadowProjector in your scene, the rendering will be different if you watch a Transparent object or not.
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Do command buffers help?
     
  4. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi, I don't know much about command buffers. I checked the documentation and couldn't find how they could help.

    Anyway, the behaviour I encounter with the projectors, is it a bug or am I doing something wrong?
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Do you have a reference to the AO texture? perhaps the answer is merely to read that texture and blend it in the shader for projector...
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
  7. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Thanks for your answer, I'll do that!
     
  8. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi guys,
    so I updated to Unity 5.5. Indeed, projectors are not rendered twice anymore. However, I still can't have my ImageEffects rendered AFTER my projector, because I can't change projectors rendering queue :

    With Unity 5.5, projectors are always rendered during the Transparent queue (so after my edge detection and SSAO), even if I change the queue in the shader or in the material.

    So my question remains: is there a way to control when projectors are rendered?

    Thanks
     
  9. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Hmm... that's annoying. Checked with 5.4.2 and it does indeed appear that they only render during the transparent pass. Seems like the "fixed" the double rendering issue by removing the pass you actually want rendering and leaving the "wrong" pass. >.<

    I would report it to the issue tracker. To me this appears to be objectively wrong behavior (though I'm also guessing it was done intentionally to work around something else).
     
  10. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    thanks bgolus!
     
  11. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Do you have the link of the issue you reported, so I could follow it? I couldn't find it. Thanks!
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I did not report it, I was suggesting you do so (as you have a use case where it is easy to show it working or not).
     
  13. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    oh sorry, I misread. Sorry about that!