sidebar features
sidebar content

Go Back   Blender Artists Forums > General Forums > Python & Plugins

Reply
 
Thread Tools
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
Hello!


This is my first plugin. I wrote it for use in my short film "Alchemy" and I thought that the community might find it useful.

It is based on zblur, but operates using a greyscale image instead of the zbuffer. This makes it easier to tweak. Also, imho, I think that my plugin gives more control and is easier to use than zblur.

source: http://cs.unm.edu/~sketch/gallery/re...dof/deepblur.c
windows .dll: http://cs.unm.edu/~sketch/gallery/re...f/deepblur.dll
linux .so: http://cs.unm.edu/~sketch/gallery/re...of/deepblur.so

The plugin requires 2 input strips. The first should be the rendered images. The second should be greyscale images that indicate the depth of each pixel in the first strip. The second strip can easily be created using the zutilz plugin which can be found in the plugin repository.

User defined variables:


Blur: Maximum radius of the blur effect.

Focus: Distance from camera to focal point.

Length: Distance from focal point that will remain in focus.

Fade: Distance for gradient between focused and blurred areas.

Show Weighting: Displays the greyscale image used to perform the weighted blur. Black areas will be in focus, while white will be blurred (and grey areas are everything in between).


For example:
Strip 1:


Strip 2 (created using zutilz plugin):


Output (using default settings):


I hope you all find it useful.
#1   Old 30-Nov-05, 18:49   
Reply With Quote


kirpre's Avatar
kirpre kirpre is offline
Member
 
Join Date: Mar 2002
Location: Rochester, New York
Posts: 555
Any chance of getting a quick step-by-step of what you did here. I have the zutilz plug-in but I can't figure out how to use it to create the depth image used by the DOF plugin you created. Any help would be appreciated. Thanks.
............................................
kirpre
#2   Old 30-Nov-05, 19:45   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
I will write a full tutorial when I have time, but until then, hopefully this will help.

Here is a screenshot of the zutilz settings I used:
#3   Old 30-Nov-05, 19:57   
Reply With Quote
UglyMike's Avatar
UglyMike UglyMike is offline
Member
 
Join Date: Mar 2002
Location: Brussels
Posts: 529
The output looks really great!

The only issue I'd have is that it is a plugin that needs the output of another plugin.... Any chance that the zutils could be encapsulated by your plugin so that only the rendered images strip would be needed (and a link to the .blend of course)

Could a python script render the image, call the zutils plugin to render the depth info and pass both to your plugin for blurring?
#4   Old 30-Nov-05, 20:02   
Reply With Quote
kirpre's Avatar
kirpre kirpre is offline
Member
 
Join Date: Mar 2002
Location: Rochester, New York
Posts: 555
So I create my scene, render it with RGBA turned on (is there anything special besides this that I need to do with the render). I import the image (will PNG do?) into the sequence editor, insert the zutilz plugin (how do I attached it to the image? Add?). Turn on "Do Sequnce" and render.

I'm probably missing a few steps or getting a few things wrong, any help would be great.
............................................
kirpre
#5   Old 30-Nov-05, 20:02   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
UglyMike: I don't see why the zutilz code and deepblur code couldn't be combined into 1 plugin. I will probably do that one day. This first release doesn't have that functionality because I didn't need it for my film at the moment .

kirpre: Here is a real quick and dirty step-by-step:
1.) Create your scene and render it. The plugin doesn't support alpha channels yet, so it doesn't matter if you use RGB or RGBA. Save the image (file format doesn't matter).

2.) Add the scene to the sequence editor. Select the scene in the sequence editor and add the zutilz plugin. Make the settings look like the ones I posted above. Click "Do Sequence" in the render buttons and render. Save this image too. (for this second render you can turn off raytracing, delete lights, delete textures, etc to decrease your rendertime. All zutilz needs is the zbuffer)

3.) Delete the scene and zutilz from the sequence editor. Add both images that you just rendered to the sequence editor. Select them both images (select the depthmap last) and add the deepblur plugin.

Hopefully that made sense.
#6   Old 30-Nov-05, 20:15   
Reply With Quote
kirpre's Avatar
kirpre kirpre is offline
Member
 
Join Date: Mar 2002
Location: Rochester, New York
Posts: 555
Perfect. Thanks for your help. I look forward to playing around with this some more.
............................................
kirpre
#7   Old 30-Nov-05, 20:25   
Reply With Quote
Phrangkk's Avatar
Phrangkk Phrangkk is offline
Member
 
Join Date: Mar 2002
Location: Southeast, USA
Posts: 340
Wow, thats a really nice blur!

I tested it, not with rendered images but just with a scene, and got some nice results.

the only thing I wish it had was the ablility to animate the focal point.

I don't know if that's limitation of the plugin as it's written now or the sequence editor.

thanks for releasing this!
............................................
Finally, a GURU!
#8   Old 30-Nov-05, 22:29   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
kirpre: Glad you got it working.

Phrangkk: Thanks for reminding me. I tried making the focal point animatable, but I was unable to get it to work. According to the online blender manual it should be possible to use an ipo to control the settings of a plugin. If anyone knows anything about doing this, I'd appreciate some pointers. An animatable focal point would be quite cool. ZBlur is supposed to be able to do this, but I never got it to work.

Also, I'm thinking about adding a feature similar to autofocus in zblur. It would focus on a certain area of the image, rather than on a certain depth. So that might be useful for animating the focal point.
#9   Old 30-Nov-05, 22:53   
Reply With Quote
malefico's Avatar
malefico malefico is offline
Member
 
Join Date: Nov 2001
Location: Argentina
Posts: 805
Cool. This kind of job I always do it in postprocessing software like cinelerra or gimp. It is great to have the chance of applying depth masks in blender itself.

BTW Only bad thing about Zutils (or any other plugin using the zbuffer) is that objects that are partially transparent (objects with a texture to define transparent areas), will not be visible at all. In those cases, only workaround I found is using the "gradient technique" explained in these forums (using a white/black blend texture with global coordinates for all objects).

Kind regards

malefico.
............................................
My studio: http://www.licuadorastudio.com
My blog: http://www.malefico3d.org
My latest project: http://mercator.licuadorastudio.com
#10   Old 01-Dec-05, 12:46   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
malefico: Let me suggest another solution to you: Because the rgb render and the depth render are performed seperately, you can make your transparent objects opaque for the depth render. Halos, however, will still be a problem.

Also, using ray transparency instead of z transparency solves the problem as well. But often this is not ideal.
#11   Old 01-Dec-05, 16:42   
Reply With Quote
paprmh paprmh is offline
Member
 
Join Date: Jul 2002
Posts: 574
@sketchy: welcome to the world of seq plugin coding...It's funny to see that you are using my first real plugin to support yours ...

A better way to do it is to just render and save

add a scene (link objects)... I'd name it Z %|

in Z, turn off all the fancy rendering stuff like sketchy said...

ztransparent means what it says ... if you want it to show up in the depth map ya gotta turn off ztrans in the materials.

now go to the seq editor (go back to your origional scene)and add scene Z and then add zutilz to it & set it as above

add your image above zutilz

select the image, shift select zutilz, and add deepblur

The reason this is better is because now you can save your blend with all the plugins set up and not screw up your origional scene. you won't have to start over from scratch if you decide to move or edit something and re-render, you can just turn off do squence and render and save. Since the objects in Z are linked to the original scene, your depth map will change with it and all you have to do is change the image (select the old image in the seq editor and hit c), and do sequence.

yeah, you can just use your origional scene strip instead of an rendered image if the rendertime isn't too bad, but if you happen to accidentally change frames while in the seq editor you will have to wait for it to render again...that can get annoying

heh, like I said, zutilz was my first real plugin...Iv'e learned alot since then - I really need to completely recode it :-|
............................................
I have found that for the most part, it is better for me to keep my mouth shut and let people think that I am stupid than to open my mouth and prove it... dang... did it again
\\//_
#12   Old 01-Dec-05, 23:49   
Reply With Quote
grzybu grzybu is offline
Member
 
Join Date: Jan 2003
Posts: 677
Hi,
Thanks for this plugin It work quite well. Any news about controlling plugin parameters with IPO?
............................................
--
Regards
Grzegorz Rakoczy
#13   Old 07-Dec-05, 12:09   
Reply With Quote
DracoFodder DracoFodder is offline
Member
 
Join Date: Feb 2005
Location: USA
Posts: 345
Quote:
Originally Posted by sketchy
linux .so: (someone please compile, and I will put a link here)
sketchy,

Cool plugin, I was afraid to try it until someone compiled the source for me... and then I got frustrated waiting. So, I compiled it. Not sure where to place the linux deepblur.so file, so I'll just post the instructions.

It was very easy. Took me a few seconds to read your source file, and realize that the compiling instructions were already there with the included zblur comments.

So...
A) copy the deepblur.c file code to $BLENDERDIR/plugins/

B) compile it with "./bmake deepblur.c"

C) this deepblur.so file is now in your plugins directory (or you could copy it off to a working plugins directory elsewhere if you like)
............................................
Imber totum diem fluit
Urceatim semper pluit.
#14   Old 07-Dec-05, 16:36   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
Quote:
Originally Posted by grzybu
Hi,
Thanks for this plugin It work quite well. Any news about controlling plugin parameters with IPO?
Yes, in fact. paprmh helped me figure it out. Once the school semester is over I will code it (this is the last week! ).

DracoFodder: I pm'd you my email address. If you email the .so to me, I'll make it available for download from my website. Thanks!
#15   Old 07-Dec-05, 19:21   
Reply With Quote
sketchy's Avatar
sketchy sketchy is offline
Member
 
Join Date: May 2004
Posts: 544
First post has been updated with DracoFodder's linux build.
#16   Old 09-Dec-05, 03:22   
Reply With Quote
!Rocky !Rocky is offline
Member
 
Join Date: May 2005
Posts: 84
paprmh's method is the only one that actually worked for me... As a sidenote, instead of using 2 plugins (too memory-intensive imo) you could just use the gradient method.

Sketchy: Would you mind explaining exactly where the focus (ie the completely un-blurred part) is, according to the script? I mean, do I have to figure out the exact distance from the camera to the focus, or is there some idiot-proof method?

[edit]
Nevermind, I figured it out. Or rather, messed around until I got something okay -- I'd still appreciate an authorised answer

~60kB DivX 5 avi

.blend file
#17   Old 09-Dec-05, 21:21   
Reply With Quote
renderdemon renderdemon is offline
Member
 
Join Date: Sep 2004
Location: Milan
Posts: 853
Hi sketchy,very interesting plug in you have made!
I'm tryng to use it to help me faking subsurfacescattering and works very well.
But can you increase the maximun radius of the blur?For animation
it's not a problem but for still at high resolution I think the radius should be increased,at least double the value(I know that in this way can be very slow but it's not a problem for me.
Bye
#18   Old 10-Dec-05, 05:31   
Reply With Quote
bigbad's Avatar
bigbad bigbad is offline
Member
 
Join Date: Aug 2004
Posts: 2,713
Do you know why the z buffer has jagged edges?? :-?
............................................
1234567
#19   Old 12-Dec-05, 19:11   
Reply With Quote
renderdemon renderdemon is offline
Member
 
Join Date: Sep 2004
Location: Milan
Posts: 853
bigbad,the zbuffer is not antialiased,it's right having jagged edges(well,it's not right but its make sense,for an antialiased zbuffer you should use the gradient method).
Bye
#20   Old 12-Dec-05, 19:33   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 15:34.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Blender Headlines
Featured Artwork
Crocodile by Julia Korbut
Classic vintage look renders by HANGAR
Blending life - Old George by bigbad
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Social BlenderArtists