Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Depth of Field is extremely hard to configure, even though I'm using a perspective camera.

Discussion in '2D' started by danteos, Jun 29, 2019.

  1. danteos

    danteos

    Joined:
    Feb 23, 2018
    Posts:
    3
    So in pursuit of adding parallax to my sidescrolling platformer game, I switched from manually moving the sprites based on camera movement to using a perspective camera and adjusting object's Z levels.

    Because the object in the background are now physically apart from each other, I figured I would try to use Post Processing's Depth of Field effect to blur sprites that are further away from the player. However, the post processing depth of field is extremely finnicky, and I have no idea how to adjust the focus distance, aperture, and focal length so the player is in focus but the background isn't. Ive spent about 2 hours on playing with the parameters and googling, and no matter what happens every element on screen is given the same amount of blur with no regards to their distance from the camera.

    The Unity documentation gives basic explanations for these parameters, but they don't make any sense when transferred into the unity editor. Does anyone have experience using DoF in 2D and could help me make sense of focus distance/aperture/focal length, or have any other solutions to adding blur to background objects?

    EDIT: Screwing around with the near clipping plane on my camera seems to have significant effects on the way the DOF Post Processing is being calculated, even though I'm not actually 'cutting' any objects by increasing it.
     
    Last edited: Jun 29, 2019
  2. TigerDawn

    TigerDawn

    Joined:
    Aug 4, 2018
    Posts:
    21
    Depth of Field is just the cut off point for objects in the distance. aka. Objects further away than the depth will not be drawn. If you are using depth of field, you are thinking 2D, but really doing it in 3D. Sort Order on canvas objects is what you should use if thinking 2D.
     
  3. danteos

    danteos

    Joined:
    Feb 23, 2018
    Posts:
    3
    Depth of Field is the blurring of objects that are further and closer than the camera's focal point, I think you're thinking of the clipping planes, which are pretty self explanatory.