djDepth phenomena

david | mentalray,rendering,tutorials | Tuesday, May 6th, 2008

Last year I wrote about my experiences creating a mentalray phenomenon called dj_mix_colors. Shortly after that I wrote about how to create a zDepthDOF shader using some of the standard maya utility nodes. Now I'm going to combine the two ideas and build a zDepthDOF style shader as a mentalray phenomena.

Let me start by saying all I'm really doing here is emulating (once again) the zDepthDOF shader by Andreas Bauer. But I have two reasons for doing so. Firstly I have recently become aware of a suite of freely available mentalray shaders called drUtilSuite 1.01 written by Duiker Research. It contains roughy 200 shaders

...to provide clearly defined atomic operations that may or may not be available already in Maya and mental ray.

Most accomplish a single basic task and they are designed to be built into something bigger. So I decided that it would be a good exercise in phenomenon building to create something useful. And that brings me to my second reason.

These shaders are provided for windows x32 and 64, linux x32 and 64 as well as osx uni, so they could fill some of the gaps currently facing those on modern os's.

You can download djDepth with some example scene files from here.

If you are interested in the full story click here to read

I started with a shader called drStateDist which computes the distance from the camera.

drStateDist_menuIcon.jpg

I built up around it a network of other nodes to do the math required. My djDepth phenomenon takes 4 inputs. The near distance, the focus distance, the focus range and the far distance. From those inputs it generates a luminance based render where black reperesents sharp focus and white is fully blurred. (But if the near distance matches the camera's near clipping plane and the focus distance is set to the same as the near distance and the focus range is zero and the far distance matches the camera's far clipping plane then the result will be very similar to maya's standard luminance depth pass.)

The resulting hypershade network looked like this:

djDepth_hypershadePhen_small.jpg

I have included this scene in the download so you can have a look at the phenomenizer connections as well.

From there I exported a phenomena, wrote an AE template and made some icons.

djDepthMenuIcon.jpg djDepthHypershadeIcon.jpg

djDepthAttribEd.jpg

Lastly I made an addition to maya's mentalrayCustomNodeClass.mel so that my phenomena would have the correct rmb-menu in the hypershade, which allows it to be assigned to selected objects - just like a real shader.

I included an example scene using djDepth where I hooked up the camera's near and far clipping planes to the near distance and far distance parameters. And it looks like this when rendered

djDepthRender1.jpg

Installation Notes

You can download djDepth.rar from my downloads page. I have included the two required files from the drUtilSuite_v101_mr_all_20070707.zip (drUtilShaders1.01.mi and drUtilShaders1.01.dll) If you want the full suite with the other os files, plus icons and documentation you can get it from Duiker Research.

As usual, the .mi files go in your mentalray include folder; the .lib files in your mentalray lib folder. The AEdjDepthTemplate.mel goes in you scripts folder.

mentalrayCustomNodeClass.mel is an edited version of a maya2008 sp1 file, so don't overwrite your original without first making a backup. In fact I would suggest putting it in your local scripts folder and leaving the maya installed version untouched. With this edited version I am hiding the drUtilSuite shaders from the hypershader menu. There are too many to have them all on display for general use. If you plan to develop your own stuff, then have a look at the mel scripts that come with the drUtilSuite_v101_mr_all_20070707.zip from Duiker Research, that allow you to expose all the shaders.

djDepth.fti and render_djDepth.xpm go in your icons folder.

When you restart maya you should see djDepth in the mentalray materials menu.

Other OS Note

I have no way to test whether my djDepth works on OS's other than XP pro (32) so if anyone gets it working on something else I would love to hear about it.

Download djDepth.rar

10 Comments »

  1. Tried it out on my Macbook Pro and it works like a charm. The drUtilSuite has saved me on many occasions as a mac user.

    Mike.

    Comment by wywait — May 6, 2008 @ 6:47 am

  2. Thanks for testing it Mike. Nice to know it works as I had hoped. Regarding drUtilSuite, do you know of any documentation other than the pdf that is in that zip file?

    Comment by david — May 7, 2008 @ 12:17 am

  3. Hey David, the plugin works pretty well, but I seem to have a problem when I'm animating the focus distance. When I render, it doesn't reflect the keyframes, it seems to continually render the settings from the first frame. Is there a special process I need to follow to correctly render? Thanks again for all your hard work!

    Comment by ariantibbs — July 2, 2008 @ 1:13 pm

  4. ariantibbs, thankyou for letting me know about this problem. I was not aware of it because I use the smedge render manager and most of my renders get done as single frames on the render-farm. I had a look into it, but so far nothing I tried gets around this problem. The only work around is to render one frame at a time - easy if you use a render manager, but very inconvenient if you dont. Maybe someone else will have a solution.

    Comment by david — July 2, 2008 @ 9:06 pm

  5. David, I use the command line on Mac OS 10.5 to do all my renders. Even when I do that, if I set a range of images to be rendered (a targa sequence for example), I still get the same results, no matter what frame it starts on, it keeps re-rendereing the initial frame.

    Comment by ariantibbs — July 3, 2008 @ 4:48 am

  6. Hmmm. I'm not sure then. It's working ok on xp and vista.

    Just to be sure I did some cmd-line tests. In one I had animated the focus distance by keyframing it directly. In the other I used a measure distance tool - one locator parented to the camera, the other locator's translate values were animated, and the distance output connected to djDepth. Both tests gave the expected results. Each cmd-line command rendered only a single frame. I had to launch it 10 times to render a 10 frame sequence.

    Maybe its a Mac issue. If you feel like sending a test scene I'll render on xp and see what happens.

    Comment by david — July 3, 2008 @ 10:43 pm

  7. I've received an email from Arian Tibbs saying he got it working on Mac OS 10.5. Here's what he wrote...
    "What I did was take the DOF rig/setup you had from your original work (the maya software render / mental ray DOF shader you wrote awhile back) and applied it to the DJ Depth shader you created. I basically rigged up a camera and distance tools etc to the camera and animated the locater that I had connected to the focal range."

    Arian also kindly packaged up a Mac version of djDepth with the required Duiker Research components. I have added it to my downloads page.

    Thanks Arian.

    Comment by david — July 4, 2008 @ 10:40 pm

  8. I just tested your shader under XP x64. It works great, but requires the x64 version of dll's from Duiker Research. http://duikerresearch.com/mental-ray/#Download. Thank you for a fantastic shader! :)

    Comment by ikaria — October 7, 2008 @ 12:01 am

  9. You are most welcome. Nice to know it works.

    Comment by david — October 7, 2008 @ 9:58 pm

  10. Just test the shader under Vista64 and Maya2009 and it works!

    Thanks a lot David and thanks Ikaria for the x64 tip.

    Now we can blur our brand new Importons+IP images ;-)

    Comment by seq — October 16, 2008 @ 11:19 pm

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck