Near DOF blur?

Is it possible to add a separate layer of depth of field for near objects? I’m asking specifically about adding a blur to a weapon as I raise it up to aim down sights, while maintaining the world DOF settings as they are.

Perhaps using a camera anim?

Ok, so I can get the effect I’m after using a PostProcessVolume:


The problem is that this then overrides the default world post process DOF settings. Anyone know of how I can have it add to the existing world post process DOF, and not replace it?

Think i might be screwed on this one. While i can get the effect i need using a PostProcessVolume or CameraAnim, in-game I render all my first person weapons much larger than they appear and set them to SDPG_Foreground. This is to avoid clipping through the camera when aiming down sights.

So to apply the DOF i want correctly on the weapon, i have to extend it’s range so far that it blurs out the nearby world also.

What happens if you set the weapons to a more realistic scale, put them closer to the camera, and change your near clipping plane? The setting is in *Engine.ini, called NearClipPlane.

So far as I can tell you can’t change it dynamically through UnrealScript alone, but it’s trivial to expose it to UnrealScript if you have C++ access.

The problem with that is that it then applied to everything in the game, which is not what i want. Looks bad for things like foliage etc if you bring the clipping plane too close to the camera.

I just noticed a different complication. In the picture you posted, the gun mesh has a sharp edge. Is that because the gun is in the foreground? The blur effect probably won’t allow the foreground to blur with the background. Even if there were a way to apply different postprocess effects to the background and foreground, there’s probably no way around that sharp edge.

The only solution that comes to mind right now is kind of a silly hack. Imagine this:

Every gun has a material that contains a sharp diffuse texture and a blurry diffuse texture. Use pixel depth to lerp between the two.