Search Unity

Depth of Field using 2D Sprites

Discussion in '2D' started by AMO_Noot, Apr 23, 2017.

  1. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    upload_2017-4-22_16-53-51.png

    So, uh. Depth of Field doesn't seem to affect sprites whatsoever, for some reason.

    As you can see in this shot, the 3D cubes are very clearly affected on my background camera, but any 2D
    Sprites are ignored and blurred the same way regardless of distance from the perspective camera.

    This is using the new Post Processing script Unity is pushing as the successor to Image Effects; although I believe it failed to work just the same.

    How can I remedy this? Do Unity sprites not write to Z-depth? Do I need a specific material or shader on these sprites in order to do this? If so, can somebody point me to an otherwise identical unity sprite shader that writes to Z-depth?

    (Edit: I've attempted to create a duplicate of the Unity default Sprite shader and switch Zwrite from Off to On; but it seemed to make no effect whatsoever.)
     
    Last edited: Apr 23, 2017
  2. okyn

    okyn

    Joined:
    Dec 10, 2016
    Posts:
    1
    I'm having the same issue.
    I've tried different dof shaders, adding z-depth but nothing worked.

    It works fine with 3d objects but not at all with 2d sprites.
    Also you can't find much information about this

    upload_2017-10-27_21-24-18.png
     
  3. karmaral

    karmaral

    Joined:
    Oct 28, 2017
    Posts:
    5
    Are you using the Sprite Renderer to render the sprites? I'm not 100% sure but I think the default sprite renderer is pretty limited in regards to rendering and effects... have you tried changing the material/shader to other than the default or even using quads? (they're technically a 3D object so you might get some luck with that)
     
  4. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    I'm also struggling with this. It's hard to find information on this issue. Does anyone know of a solution?
     
  5. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432
    I also think that using quads would be the first thing to do for that type of things, didn't work for MrTenda ?