0 like 0 dislike

I'm trying to reach an effect like the one below with DOF in Unity. 

Unfortunately, I cannot seem to get the integration correct. After importing to Unity, none of the DOF Attributes from the FX seem to have any effect (see below for settings I tried). After trying the Unity DOF script (with Has Post Fx ticked on the camera), the only slider that seems to have any effect is the Far Plane Blur Radius. It seems like all of the particles are getting the same depth, so the farthest particles are blurring the same amount as those nearby.

I've already tried:

  • enabling Soft Particles (after switching to all soft materials) in the Rendering Plugin camera script
  • switching back to DX9
  • setting PopcornFX Preferences to "Before Image Effect"
  • the two camera solution found here
  • countless near plane, far plane, focus and range settings
  • multiple combinations of each
Here's the effect I'm still getting:
Everything is either blurred or not depending on the Far Plane Blur Radius. Also, I've noticed that the DOF_FocusDistance affects the logo seemingly correctly when changed, but nothing else.
I'm probably missing something extremely simple, but does anyone have any ideas?
by Addison (170 points)

1 Answer

0 like 0 dislike
Best answer

Hello Addison,

First of all, do not use the two camera solution described in the wiki, it is a mistake from us to have let this page on the wiki as this has been fixed natively with the "Use Depth Grab to Z Test" checkbox on the PKFxRenderingPlugin component. Furthermore, this is only useful when using post-effects with DirectX 11, as a bug in Unity makes the depth invalid after some post-effect scripts.

Then, it is totally natural that Unity's depth of field script does not work on particles as they are semi-transparent objects and they do not write to the depth buffer. Only solid objects can be affected by a depth of field and this is why the depth of field is handled directly in the effect by changing the color, size and/or texture of the particles.

By looking at this effect, I have realized that it uses two attributes "ViewPosition" and "ViewDirection" which are deprecated. Those are supposed to be replaced by the position and direction of the camera, but there are new helper functions in the script to retrieve those attributes:
So you should try to remove those two attributes and replace them in the script with view.position() and view.axisForward(). Hopefully, this should work.


by Paul (7.9k points)