WaveFilter Net+ DOF Tutorial


We will examine the nulls, what they do and the optimal settings to get great DOF.  Let's cover the nulls one at a time, let's talk about how to use LWs fog radius to find how the focal point will effect the image and find the keys to setting the DOFBlur% and MaxDOFBlur% variables to get a smooth increase in blur over distance to get the deepest image possible.

When you load the nulls into the scene, you added 7 nulls. 5 of them use the Z distance in meters for control, 2 of them use the x,y,z 3D location to solve for a distance. Each works as follows:

1Blur% controls the amount of blur to add to every pixel of the image. If DOF is your goal, this null needs to be set at zero meters on Z. If it is set higher then zero, then the amount of blur specified will be added to the whole image, meaning that even the portion of the image in perfect focus will have the amount of blur specified.  Usually you just set this null to zero for DOF effect, or set the DOFBlur% to zero if you want a full image blur without DOF.

1Softer controls the two types of blur built into Net+. I ONLY use the softer blur as it is just slightly slower and gives a perfectly soft and nice round blur effect. To get the softer blur, move the 1Softer null to 1 meter on the Z axis.

1DOFSeperator is a strange control I added for one customer for one shot and I wish I never had, it's the most confusing control in DOF. My answer, ignore it. But to make it not effect your image, you need to set it to 999999 meters on the Z axis.

1MaxDOFBlur% controls the greatest amount of blur that any pixel will receive. This has the greatest effect on rendering speed of any setting, so keep it as low as you can and still achieve the desired effect.

1FocalPoint is a 3D, distance based, control. The distance from this null to the camera defines the center of perfect focus. It's important that you remember that it defines a distance from the camera, so it defines a sphere around the camera. Any object that intersects that sphere will be rendered in perfect focus. I often use the fog settings on the camera to have LW display the fog radius around the camera. If you adjust the fog radius to intersect the FocalPoint null, you can see the sphere around the camera and get a better idea what portions of the scene will be in perfect focus.

1FocalRange is parented to 1FocalPoint and is used to open the area of perfect focus. The distance from the focal point to the focal range is added and subtracted from the distance from the camera to the focal point to define the near and far points of perfect focus centered on the focal point. Example: If the focal point is 10 meters from the camera and the focal range is 1 meter from the focal point, then the near edge of perfect focus is 9 meters from the camera and the far point of perfect focus is 11 meters from the camera. Blur is 0% at these edges and increases as the distance toward or away from the camera increases. So the whole range 9 to 11 meter is in perfect focus and at 9 meters moving toward the camera the blur increases and at 11 meters and moving away from the camera the blur increases.

1DOFBlur% may be one of the most important settings to getting the best DOF effect. You will notice I saved it for last as you need to set it last. To set it correctly, first define the place in your scene where you want the blur to reach MaxDOF%. Following the example above, lets assume the distance where you want to reach max blur 16 meters from the camera. Then find the distance from the edge of perfect focus (11 meters in this example) and the point where you want max blur (16 meters in this example) and you get a total distance of 5 meters from perfect focus to max blur. Call this distance value D. Then to set DOFBlur% correctly, use this formula. DOFBlur% = MaxDOFBlur% / D. Assuming a MaxDOFBlur% of 150%, using our example, that means DOFBlur% = 150 / 5, so use 30% for DOFBlur%. That way 1 meter past perfect focus you get 30% blur, 2 meters past perfect focus you get 60% blur and that continues until you reach the 150% Max blur we set in the example. By using the formula to set DOFBlur%, we assure that the blur gradually increases smoothly until it reaches the point you selected for it to reach max blur.

One more very important point, DOF hates infinity. It uses distances to define the amount edges blend and the amount of blur to apply. So when it sees infinity it kind of freaks out. Because of this, simply put a large box around the scene that is 99.9% transparent. That way the background is a real distance from the objects and the math all works right.

Challenges with the Z Buffer and Workarounds Each of the challenges with Net+ and DOF stem from the use of the LightWave Z buffer.

1) The first challenge is that there is only one sample in the Z buffer for each pixel. This means that if a transparent object is rendered, it's distance is recorded in the Z Buffer and objects seen through it are not correctly blurred. The only work around to this is to render in layers. Render the scene without the transparent object, then use that as a front projection map on all surfaces when you render the transparent objects and use the special buffers to only use Net+ on the transparent objects, or use the original image as a background image and only have Net+ effect objects.

2) The second challenge is that the Z Buffer is not antialiased. To get around this challenge, render your images with no AA. I know that sounds foolish, but the trick is that you render the AA data in the image by rendering the image LARGER! You size the output X times larger, where X is the number of AA passes you desire. This does take more memory, but it is about equal to rendering the image with adaptive sampling turned off. Every pixel gets rendered for all the AA passes. Now that you have this HUGE image, run it in a second pass on a polygon that fills the screen and output at the original resolution required. But in this pass turn on AA at the level equal to the level you selected to render the HUGE version at. (i.e. Low = 5 passes, so render the HUGE version 5 times larger and then use Low AA in the second pass.) I also find you can cheat this a bit. Use more AA passes in the second pass then you included data for in the first pass, it's a hack, but it works and can save you time. Test for best results.