Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Overzealous near plane culling

Discussion in 'General Graphics' started by realworld666, Dec 23, 2014.

  1. realworld666

    realworld666

    Joined:
    Nov 2, 2012
    Posts:
    24
    Anyone got any ideas on the correct way to fix this?
    Our game has a near plane as near as Unity will allow. Anything beyond the near plane is culled by Unity. We have a shader that applies an offset to the vertices of objects within our scene. As a consequence, some of the objects that have been culled by Unity are moved back on screen slightly, causing noticeable pop-out of game objects.
    It seems as if the order of culling and vertex shader are the wrong way around. Is there a way to fix this or to get Unity to cull a little later than the near plane position?
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The problem is that the bounding box of the object does not get / can updated after the vertex shader does his work.
    Unity will cull the object before the rendering begins.
    The simplest way is to estimate the biggest size of the objects after they are deformed by the vertex shader and correcting the bounding-box beforehand. (If its very varied you can calculate the size via code) This may cause unity to render more objects then 100% necessary but you will get no plopping.

    Ps: "near plane as near as Unity will allow" is not the best idea.
    You should the the near and far plane as near to each other as possible for your scene.
    That way you get a better depth resolution witch can reduce flickering and shadow problems.