Search Unity

Deferred lighting breaks depthmask?

Discussion in 'Shaders' started by Gobla, Jul 16, 2013.

  1. Gobla

    Gobla

    Joined:
    May 28, 2012
    Posts:
    354
    Hey All,

    I'm following the following (semi) tutorial: http://www.blog.radiator.debacle.us/2012/08/how-to-dig-holes-in-unity3d-terrains.html

    All is working fine except when I switch to deferred lighting and a dual camera setup. I think I understand that this is due to the rendering pipeline and that the latest rendering camera overwrites the buffer, but I have no idea how to fix this.

    Since I am using the custom terrain shader that uses normal mapping and quite a lot of light sources, I was wondering how I could make this work?

    Thanks in Advance.
     
  2. Gobla

    Gobla

    Joined:
    May 28, 2012
    Posts:
    354
    Here I have an example of what the scene looks like in forward rendering:
    http://www.minitankbattles.com/IslandOfFreedom/IoF_Web_Ghost/



    For simplicity I make a difference between the "ghost" and "real" world. The ghost world is encapsuled by the mesh in the center of the scene.

    Extra info:
    • The towers only exist in the Ghost world.
    • The red lined spheres only exist in the ghost world.
    • The blue-ish lined spheres exist in both worlds.
    • The purple lined spheres exist only in the real world.
    • The wall only exists in the real word.
    • The floor exists in both worlds.

    Edit: the mesh is shaking due to this effect I was trying out. This is normal.
     
    Last edited: Jul 16, 2013
  3. Gobla

    Gobla

    Joined:
    May 28, 2012
    Posts:
    354
    I've got the deferred rendering working now except for the image effects. This is the same when I render a scene side by side without the mask. So the next question is:

    How can I maintain the image effects if two camera's are rendering the same scene?
     
  4. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    232
    How did you get the depth mask working in Deferred?
     
  5. lcellentani74

    lcellentani74

    Joined:
    Dec 4, 2011
    Posts:
    31
    @gobla: I'm facing a similar problem.

    On my case I assigned a different camera depth value to the cameras in the scene and I'm applying image effects on the camera with highest depth value.
    Image effect should be also applied in order they appears on the Inspector.

    At least this is what I have collected reading around.