zutilz_float plugin for mask or grayscale output based on the zbuf

 a float aware update of zutilz for blender versions2.43-2.49

Note: Sequence plugins will not work in 2.5
 The plugin api that this was based on will not be ported  to blender 2.5+


 

source: zutilz_float.c  

 linux: zutilz_float.so 

 windows: zutilz_float.dll 

 mac intell: zutilz_float-mac-i386.zip 

thanks go to Lguillaume for the windows build

and to youngbadcat for the mac intell build 

 zutilz float takes advantage of blender's new float zbuffer which is based on the actual distance (in blender units) from the camera to each pixel in an image.  This makes it much easier for the user to make sense of the min and max values used for zutilz which gives you a mask or grayscale output based on the zbuffer

At the moment, a scene strip does not return a zbuffer to the seq editor (I have submitted a bug report) so the only way to get zbuffer information into the editor is to save your image as an openEXR +Zbuf and use that in the sequencer.  Be sure to have the resolution the same as you did to render the .exr because although blender will resize the image to the new resolution automatically, it does not change the zbuf and zutilz will not work properly...

Update Nov 1, 2006: today Ton added the float zbuffer to scene strips in cvs so zutilz_float will now work with scene strips with any new build after this date

I made this scene just to illustrate how zutilz works, each tile on the floor is 1bu and the camera is 10 bu's from the front of the floor.   The actual zbuf values are slightly different because of the angle of the camera. You should see your original image in the preview window when you first run zutilz.

 

 

 

If there is an error you will get a checkered inverted image.  Make sure the info button is on and then check the console to see what is wrong

Using zutilz

When you have the plugin selected and press "n" you get the properties tab which has all of your options for the plugin.  The default settings are shown. 

 

 

Depth map:

The depth map button gives you a greyscale gradient of the zbuffer from min to max and anything outside  of that range is masked to the selected mask color and alpha.  The normal gradient is from black(closest) to white(farthest).   This output is with both autoselect and inv gradient on, giving you a white closest full depth map of your scene.

viewZ/DOFmask 

The viewZ/DOFmask button is a 3 way toggle button.  The first click puts you in viewZ mode which is handy for setting your min and max values when you want to work with just part of the zbuffer .  The red->yellow gradient shows the zbuffer below min and the blue->cyan gradient shows the zbuffer above max.

(remember: the actual zbuf values are slightly different because of the angle of the camera.)

  This is with autoselect off, min=20.20, max=22.18, invgradient on

 

The second click is dof mask mode, a simple double grayscale for quick dof blurs.   

This is with autoselect off, min=20.20, max=22.18, invgradient off.

White would be max blur

 

 

This is where the DOF clip buttons come in handy. Sometimes you may want to clip the gradient (near, far, or both) for your dof mask.

In addition to the above settings, this is with DOF clip on, near=.4, far=.8

 

 

 

maskZ/invmask

The maskZ/invmask button is a 3 way toggle button.  These allow you to mask your image according to the min & max values. The first click masks out the selected z values

This is with autoselect off, min=20.20, max=22.18

 

 

 

The second click masks outside of the selected values

This is with autoselect off, min=20.20, max=22.18 mask color red=0, green=1, blue=0, alpha=0.1  

 

 

 

 use ibuf2

If you ever want to use zutilz on an image that took hours to render because of ray, shadows, AO and other render options  without the long wait to rerender and save as an exr, you can use this option. Open the original blend file and add a new full copy  of the scene and rename it.   Then, in the new scene, turn off all of the extra render options, get rid of any fancy lighting (just have one sun lamp) and textures.  All you want from this scene is the zbuffer and a quick render.  Now render this scene and save as exr +zbuf.  Then go to the seq editor and add your original image(any file type)  and your new exr with zbuf.  Select the original image, shift select your exr and add zutilz_float.  Initially you will get an error screen but just toggle use ibuf2 on and the zbuf will be used for the original image.

sample console output before use ibuf2:
Zutilz float...frame #42...(1280x1024)...
ibuf1: /home/paprmh/prog/plugins/zutilzfloat.png
No float zbuffer present...
ibuf2: /home/paprmh/prog/plugins/depth4a.exr
with zbuf...strip 2 zbuffer is avalable for zbuffer data...

     ->toggle [use ibuf2] to use ibuf2->zbuf_float for working zbuffer


and after:
Zutilz float...frame #42...(1280x1024)...
ibuf1: /home/paprmh/prog/plugins/zutilzfloat.png
No float zbuffer present...
ibuf2: /home/paprmh/prog/plugins/depth4a.exr
with zbuf...strip 2 zbuffer is avalable for zbuffer data...
using zbuffer imported from ibuf2->zbuf_float...working Z-buffer detected...

The float zbuffer shows the actual distance
from the camera to each pixel in blender units[BU's]
the closest pixel is at 10.0310 BU's
the farthest pixel is at 43.9232 BU's
This frame's closest and farthest pixels are 33.8922 BU's apart
auto select on [toggle off to change selected min and max]
   Selected range starts  10.0310 and ends  43.9232 from the camera

Zutilz mode: lurking

info/TMI
This button causes the plugin to print information of the images and plugin operations to the console. If you click it again, you will get (perhaps) Too Much Information