Search Unity

2 Cameras, 1 Rendertexture, still have depth?

Discussion in 'General Graphics' started by mbowen89, Sep 16, 2015.

  1. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    So I'm trying to make these denser forests on mobile. As you can imagine, even if all trees are billboarded, there's so much alpha clipping full screen that it just drains the fps.

    I had this brilliant idea that what if I had a second camera that only rendered the trees, into a render texture that's 1/2 res lets say. And then using the UI, display that texture.

    I did this, setting the second camera to clear solid color white, and then on the UI I used a custom shader to discard anything all white. That leaves me with a UI texture on screen that has all the terrain trees cutout just fine. However, a 3D object in between the trees is simply behind the entire texture, which makes sense.

    I need to figure out if it's possible to still somehow get depth working here. This method really helps with my FPS, just doesn't do depth correctly.

    I'd appreciate any insight!

    In this first image you can see how the object is in between billboard trees, like it should with depth:

    sv.jpg

    And here is what it looks like in the game view, the tree rendertexture is just overlayed on top:

    gv.jpg
     
  2. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639