Search Unity

Is there anyway set a renderer not visible in OnWillRenderObject/OnPreRender fast?

Discussion in 'General Graphics' started by dongch007, Dec 15, 2018.

  1. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    41
    I know a renderer have passed frustum cull and visible after OnWillRenderObject.
    I want do some occullsion cull.
    Now I use renderer.enable = false in OnPreRender and renderer.enable = true in OnPostRender to set occludeed renderer not visible,but after some test, set many renderer's enable opertation cost even more than occullsion cull cost.
    Is there any way to tell Unity not render this renderer fast in this point?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    The layer system won't work since that's handled during the culling. The built in occlusion system, or using an CullingGroup is generally the way to go here.
    https://docs.unity3d.com/ScriptReference/CullingGroup.html

    The other way to go about it is to not use the built in renderer components at all, or at least leave them disabled, and use DrawMesh / DrawRenderer commands with a command buffer to draw objects when wanted.
     
    xVergilx likes this.