Search Unity

Problem with HDRP depth of field post process not applying focal blur

Discussion in 'Linux' started by ajz3d, Mar 22, 2020.

  1. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    I'm experiencing an odd problem with depth of field in Unity 2019.3.6f1 with HDRP 7.1.8 and 7.3.1, and Unity 2020.1.0b2 with HDRP 8.0.1.

    Focus Distance parameter darkens/brightens near/far planes. Focal blur effect is not applied at all.

    hdrp_dof.gif

    camera.png hdrp_postprocessing.png

    I'm wondering if this is a user error on my side, or perhaps a known problem.
    For what it's worth, I tested DOF with a standard processing stack outside HDRP, and it works perfectly fine on both, OpenGLCore and Vulkan.

    I'm running Unity on Debian 11 (Bullseye).
    OpenGL 4.6.0
    Vulkan 1.2.126
    nvidia-driver 440.64
     
  2. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    Okay, this was evidently a user error coming from the fact that I was using a physical camera, but with incorrect lens settings. Eventually, after configuring those settings to match specifications of existing camera/lens, I managed to get a decent focal blur.

    I guess working with DOF of physical camera in HDRP is less forgiving that working with traditional post-process stack in the standard pipeline. :)

    hdrp_dof.jpg
     
  3. alimpo83

    alimpo83

    Joined:
    Oct 3, 2012
    Posts:
    55
    Can you tell me which settings you've used? Having the same problem you've had and not being able to solve it.
     
  4. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    Yes, I can. I basically copied values from one of the photo samples that can be found on dpreview.com. I used camera specifications of Nikon D6, but I don't remember which lens that reference sample used.

    cam.png post.png

    Then I adjusted light intensities:
    • 8000 lux for directional light
    • 3500 lux for environment light (noon_grass from HDRI Heaven)
    Which are pretty low, considering that direct sunlight has 32000 to 100000 lux and indirect daylight between 10000 and 25000, but go figure.

    What I have noticed, is that some lens settings, which use low aperture values, will turn distant focus plane into a green opaque one. For example, 185 mm, 1/250 sec, f/5.6, ISO 100 [1] with focus distance of 3.1 m looks like this:

    green.jpg

    I haven't figured it out yet why this happens.

    [1] Settings based on: https://www.dpreview.com/sample-galleries/0568827096/nikon-z5-sample-gallery/2988943154
     
    JumpingGuy likes this.
  5. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    A short update.

    The results from my two last posts come from Unity 2019.3.6f1 with HDRP 7.3.1 which works quite well so far.

    I just tried Unity 2020.1.0b3 with HDRP 8.0.1, and the problem I described in my first post is still there. DOF simply does not work.

    Maybe the culprit in this version of Unity/HDRP is a huge number of "assertion failed" errors that kept popping up during HDRP package installation? There were at least three of them which Unity kept throwing ad infinitum (see: attachment), filling the log to almost 10 MB in a couple of minutes. At some point I had to stop this endless loop by terminating Unity process.
     

    Attached Files:

  6. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    I just installed 2020.0.b4/HDRP 8.0.1 and fiddled with DoF settings a bit more in hope that maybe the issues I mentioned have been fixed. Unfortunately not, but I did discover two interesting phenomena...

    It seems that if DoF resolution in post process volume profile is set to Full, neither the Game window nor Camera Preview will render the focal blur. It will only start to appear if resolution is set to anything but Full.

    This first screenshot was made with DoF Resolution=Full:

    dof_resolution_full.jpg

    On the second one I set it to Half:

    dof_resolution_half.jpg

    The last screenshot shows resolution set to Quarter:

    dof_resolution_quarter.jpg

    On all three screenshots Focus Distance is set to 25.4, which is about the distance from camera to a capsule located roughly at the middle of the screen. Camera settings are: 35 mm, 1/200 sec, f/12, ISO 200.

    Now, the funny part. With DoF resolution set to Quarter, if I decrease Focus Distance from 25.4 to 25.3, what happens in the Game window is this:

    dof_resolution_quarter_dec_fdist.jpg

    If DoF resolution is set to Half, the "exposure" is overblown with Focus Distance lower than 23.7, and for Full resolution - at 21.39.

    But that's not all. By gradually lowering Far Blur->Max Radius while decreasing focus distance, I can delay this sudden brightness explosion from happening. So technically speaking, with greatly reduced Max Radius I can focus on close objects, but at the cost of having very little to no focal blur, and of course with reduced DoF resolution.

    Can someone from Unity comment on this issue please?
     
  7. ajz3d

    ajz3d

    Joined:
    Oct 12, 2015
    Posts:
    31
    I finally figured out how to get depth of field up and running in HDRP.

    It turns out that the key to success was to increase bit depth of post-processing Buffer Format to 16-bit RGBA. This setting can be found in HDRP Asset→Post-processing. Additionally, I had to raise depth of field blur sample counts to high values, like 16/48 for near/far planes. In general, the greater the max radius of a DOF effect, the more samples it needs. Otherwise, either various color artifacts will start to appear on low focus distances, or the focal blur will be barely noticeable. This must be done in HDRP Asset→Post-processing Quality Settings→Depth of Field, because Sample Count in Depth of Field volume override is capped at 8/16 (near/far), which isn't enough.

    Of course, DOF sample count that high has severe impact on performance, but at least it's a working solution for stills and offline rendering.

    I wonder if this quirk is specific to my machine, or it's something related to Linux/Vulkan builds of Unity. When I was looking for a solution to this issue, I watched multiple videos on HDRP DOF which were recorded on MS Windows platform, and in every single one of them DOF seemed to be working flawlessly out of the box. With this said, it would be great to hear from fellow Linux users about their experiences with HDRP's depth of field.
     
    Art-Leaping and LukaKotar like this.