Search Unity

Change Rendering Order

Discussion in 'Shaders' started by MaT227, May 27, 2015.

  1. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Hey everyone,

    I am actually trying to change rendering order of some objects. Here is an example of what I am trying to do.

    screenshot.jpg

    I've made some tests but without any good results as sometime the shadows disappears, multiple cameras doesn't work, etc.
    Anyone has an idea on how can I do that (Stencil, Render Queue, Depth, etc.) as I am using deferred rendering ?

    Thank you very much.
     
  2. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Any idea ?
     
  3. AlexBM

    AlexBM

    Joined:
    Mar 26, 2015
    Posts:
    16
    So if you want to violate depth laws and render some objects on top of others you need to manipulate rendering order and how objects treat depth buffer. There are multiple way to do that, such as:

    1) Make you second objects be rendered after first using RenderQueue and render it with ZTest Always
    2) Switch off ZWrtie on the first object and render second on top of it
    3) Render second object on top as you would normally do, but clear depth buffer just before doing it
    etc.

    Also it's not exactly clear what is displayed on your illustration. Are those a glass windows? Are they transparent?