Search Unity

Depth-only camera leaves smear as objects move

Discussion in 'Image Effects' started by dgoyette, Feb 15, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Hi,

    I have a second camera set to Depth Only, and with its culling mask set to only see a specific UI layer. On my UI layer, I have some Images, and I have one set up to spin in place forever. I'm sending the output of this camera into a RenderTexture, and using it as a material. Here's what that looks like when everything is stopped, with the material on a cube:

    upload_2018-2-15_16-16-13.png

    However, when I run the scene, the icon that I've configured to move ends up with some blur around it:

    upload_2018-2-15_16-16-54.png

    This doesn't happen if I set the UI camera to clear Solid Color, but it happens if I clear Depth Only. This confuses me, as I thought this was the exact case where I'd want a depth-only clear on the camera. The main camera is set to clear a solid color, and has a lower "Depth" than my UI camera.

    Is there something obvious I'm missing with my RenderTexture material?

    Thanks,

    -Dan
     
  2. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Setting clear flags to "Depth Only" will do what it sounds like - it will only clear the Depth buffer, leaving the color information as it is. It means that it leaves currently rendered "stuff" and renders on top of it. If it updates only a portion of the screen, all that has been rendered in previous frames will remain there, thus "smearing" effect. So it's totally expected behaviour.

    Can you tell us what you are trying to achieve?
     
  3. ruijiew

    ruijiew

    Joined:
    Jan 27, 2019
    Posts:
    1
    Trying to do something similar as well, expect my goal is to not have the color information over draw and get rid of the smear effect, while keeping the background transparent. Any thoughts on how this can be achieved?