Search Unity

Odd "Solitaire" Effect when using the SetRenderqueue/Mask tutorial

Discussion in 'Shaders' started by PylonCrow, Nov 11, 2019.

  1. PylonCrow

    PylonCrow

    Joined:
    Mar 29, 2017
    Posts:
    9
    upload_2019-11-11_15-26-1.png

    When looking through the mask everything seems to render except for the skybox, the skybox creates this odd "solitaire" effect. The wall is using A queue depth of 3000, the mask is at 2700 and the Cylinder im using to cut the hole is using 2500
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    The way Unity renders the game view when the camera's clear is set to SkyBox is like this:

    Clear Depth Only
    Render all Opaque queue range objects.
    Render skybox.
    Render all Transparent queue range objects.

    The idea is the opaque and skybox will replace the color contents entirely, meaning the color data doesn't need to be cleared. The order is important because the skybox only renders to the areas where the depth buffer has not been written to, which was changed with Unity 5 as the default skybox shader is a lot more expensive to render than it used to be. When you render a transparent but still depth writing shader as part of the opaque queue, the skybox doesn't render to those areas it covers. The result being that you see the uncleared color buffer from the previous frame(s).