Translucency material on a plane not working with cinecamera with correct Depth of Field

Hi,

The issue that I am seeing is related to translucent material. I have stacked three translucent planes in front of the camera that I am dollying into to create a depth of field effect and to focus on the cube behind it. The issue is when I try to put opaque object behind the translucent object, the area of the opaque object that is inside the focus distance would become visible when should be a depth of field effect on the translucent object. I would like the blur effect to take place over seeing through the plane.

The following screenshot is showing the issue

[Image Removed]

if I hide the cube the blur effect comes back:

[Image Removed]

I am wondering

  1. if this is because the dof effect doesnt take the plane depth into account during rendering?
  2. Or is it because of the focus distance is a bit too close for the opaque object and the translucent plane?
  3. Is there a more effective way to achieve similar look?

Projects Repo:

From the DOF project, there is a level and a level sequencer under “/Game/Developers/weizeng/Collections/DOF”.

Steps to Reproduce
Steps to reproduce:

  1. Create new level new level sequence
  2. Spawn a cinecamera into the level sequencer
  3. Translucency Material Creation:
    1. Blend mode -> Translucent
    2. Shading model -> Unlit
    3. Translucency Pass -> Before DOF
    4. Color Parameter -> Out Emissive Color
    5. Opacity Parameter -> Out Opacity
  4. Opaque Material Creation:
    1. Texture parameter -> Base Color
      1. Texture = UVEditorColorGrid_Color
    2. Roughness Parameter -> 0.5
  5. Camera Settings
    1. Aperture -> 1.2
    2. Focal Length -> 75mm
    3. Focus Method -> Tracking of the cube (foreground)
    4. Camera Movement: Dolly in while focusing the cube

After some digging, there is an option called “opacity mask clip value” in the translucent material that I can changed. Surface will not render when OpacityMask Less than OpacityMaskClipValue, so that means the plan need to have a greater opacity value than the opacity mask clip value in order to be consider to render out with depth?

Hello,

Thank you for reaching out.

Based on your test project, it looks like this is a result of order of render operations. The translucent material will properly receive DOF blurring if Output Depth and Velocity is enabled. However, this will cause the cubes behind the plane to remain blurred as well.

Post Processing materials featuring UserScene textures can be used to work around the order of operations.

Try an approach like this:

  1. Enable Custom Depth Writes and assign the cube in focus a stencil ref value.
  2. In a post process material, set the blendable location to Before DOF. Set the UserSceneTexture name to “Unblurred” and output SceneTexture:PostProcessInput0. Enable stencil test, set compare to equal, and use the cube’s Stencil Ref value.
  3. In a second post process material, get the “Unblurred” output with a UserTexture node. Use the cube’s stencil ref value to interpolate between the “Unblurred” output and PostProcessInput0

Depending on your goals, you may want to manipulate the blending values on these post process materials to refine or animate the result.

Please let us know if this helps.

Hi Sarma!

Thanks for replying, while I was trying to setup the user scene texture, there are some issues that I am noticing with a translucent plane with an unreal logo texture applied, I tried to focus on the cube so that some of the logo would also be in focus. What I seeing is a hard cutoff of the blur effect at the edge. Is this still the order of the rendering process that is causing this?

[Image Removed]

I also tried path tracing with camera setting PathTracingEnableReferenceDOF turn on, and that give mostly what I am looking for.

[Image Removed]Would there be a way to achieve this look with ray trace or lumen?

Scene setup:

[Image Removed] Thanks

Wei

Hello,

Thank you for reaching out.

In a non-path tracing scenario, using custom depth will help with the custom object sorting that is needed to achieve this desired visual.

If you cannot use the suggested workflow from above, you can try a combination of these to develop a custom solution that will fit your needs.

  • Translucency Pass and Output Depth and Velocity values in materials
  • Custom Depth and Stencil masking using Custom Depth Stencil Write Mask for complex custom overlapping
  • Post Process materials for capturing and outputting masked objects at different render passes

Please let us know if this helps.

Thanks for replying, Sarma.

Do you happen to have an example of this using custom object sorting for the unreal logo to be in focus while the opacity/translucent part being blur like the path tracing.

Cheers

Wei

Another question: Is there any way to control the focus cutoff range so it doesn’t show the popping from blur to focus of those logos. It should stay blur for those logo.

[Image Removed]

Hello,

You can animate any of the DOF related properties on the Cine Camera actor. For example, you can add the FocusOffset property to the timeline and add necessary keyframes with the desired values.

Please let us know if this helps.