Search Unity

2d Depth of field

Discussion in '2D' started by zfh2773, Feb 1, 2020.

  1. zfh2773

    zfh2773

    Joined:
    Nov 16, 2019
    Posts:
    27
    Why does the sprite not have near and far depth of field blur, only 3d objects have it. If the sprite is in front of the 3d object, adjust the 3d object and the sprite has depth of field, for example:
     

    Attached Files:

    • Why.png
      Why.png
      File size:
      34 KB
      Views:
      427
  2. zfh2773

    zfh2773

    Joined:
    Nov 16, 2019
    Posts:
    27
    I use the URP renderer, not 2d. If you use the 2d renderer, the change in the depth of field distance of the 3d object will disappear.
     
  3. Tom-Atom

    Tom-Atom

    Joined:
    Jun 29, 2014
    Posts:
    153
    Not experienced in this too, so just guess... I think, that DOF effect needs depth information. But sprite shaders do not write into depth buffer (it has "ZWrite Off" in shaders). So, effect is taking depth information below sprite.
     
  4. zfh2773

    zfh2773

    Joined:
    Nov 16, 2019
    Posts:
    27
    Thank you for your answer!
     
  5. zfh2773

    zfh2773

    Joined:
    Nov 16, 2019
    Posts:
    27
    [MEDIA = youtube] 6DRJtgHfSSI [/ MEDIA]
    When would I add a similar sprite depth of field effect?