Search Unity

Make Render Texture reflect Terrain only ?

Discussion in 'General Graphics' started by Quast, Jan 2, 2020.

  1. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Hi.
    In my scene there are many objects. I make a mirror from Render Texture. It's possible to make it reflect the terrain only ?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Use a layer.

    Give the terrain its own layer, then set the reflection camera to only see the terrain layer by setting its culling mask.
     
    Quast likes this.
  3. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Good. One more question.
    Does this method of reflection cost more frame rate ? Will this effect the game speed ?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Does using layers and a culling mask make a camera render slower? No. It’ll be faster to render only the terrain vs rendering everything in the reflection.

    How much faster? Depends on a lot of factors (like how much other stuff is in your scene, and where your bottlenecks are for performance). Potentially a lot, also potentially you’ll see almost no difference in frame rate.
     
    Quast likes this.
  5. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Thank you so much Bgolus.
     
  6. sirleto

    sirleto

    Joined:
    Sep 9, 2019
    Posts:
    146
    Ben, or someone else, what can i do to change on the fly what to render (via a camera into a render target).

    1. can i reasonably assume setting layer masks n times every frame (from their normal masks, to some special mask i need for this 1 camera, then back to their previous masks again) is fast?

    2. any other way how to tell (via a command buffer, perhaps?) which objects to render on a camera?

    3. AFAIU the amount of layer masks is limited ?
    4. and there are special rules for how many can be disabled on deffered rendering?

    thanks for any help or pointers to documentation / articles / examples