Making an image with Depth of Field
I was trying to make a picture with some depth of field effect. The goal was to make a picture similar to this one:
I had the content in Unity already, so I decided to learn how to build it completely in Unity.
I decided to do it in the URP pipeline, since it is the preferred pipeline at the moment, I switched my project to URP.
First I failed to figure out the proper setting for my image. I could get the back of the image to be fuzzy, but the front part stayed sharp.
I was wondering if it was a bug, so I set myself up to make something reproducible, I downloaded the latest editor (2021.2.11.f1), and used the 3D Sample Scene.
I duplicated the workbench to have 3 of them aligned, and move the camera to look at them from the side. Here is the top view in the scene:
I added a global volume in the scene , and created a volume profile in the inspector. Then I added a depth of field override to the volume, and started playing with it.
In gaussian mode I got to this result (trying to focus on the bench in the middle):
Not very satisfying, as I wanted both the near and far workbench to be fuzzy. Then I switch to the Bokeh mode, and adjusted the values. Here is what I got:
To be noted: the camera position is important. If you want to notice the blur in front of the object, the camera needs to be close to the object, as the blur will be increased from the focal point to the camera (or the beginning of the volume box, if use in local).
So now that I knew the URP pipeline could give me the results, I switched back to my project.