Scripting challenge: fake z-depth render

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Scripting challenge: fake z-depth render

Post by kdiddy13 »

Hi all,

Last time I asked for a script, I was suprised at how quickly I got a working response (hat's off to 7feet for his Maya camera scripts, nice job!). So, being encouraged by people giving me what I asked for :wink: I'm going back to the genius well and asking again.

Would it be possible to create a script that could render out a grayscale image representing z-depth. Basically, many 3d renderers allow you to render out an image that contains RGBA and Z, where z is a value between 1 and 0, 1 being closest to camera, 0 being furthest away.

Here's one possible application of it, animatable depth of field:
http://www.cgarchitect.com/vb/showthread.php?t=3062

Now I imagine it wouldn't be possible to create a renderer that deals with z-depth on a pixel by pixel level, but would it be possible for it to deal with objects or layers? Would it be possible to change the colors of an entire layer based on depth? Also, would it be possible to animate those colors?

I'm guessing that some things won't work very well with it, like layers that extend through z (floors and walls, etc.). I see it as you save out an alternate version of your file, and run the lua script, changing your beautiful animation into a grayscale ghost show. Render and you've got your z-depth. The lua script, of course, being the tricky part of all this.

Anyway, just thought I'd ask.

Thanks for listening.

Kurt
Last edited by kdiddy13 on Mon Mar 07, 2011 4:55 am, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Damn you, you keep coming up with ideas I like!

Doing by object would be a lot more complicated, but doing it by layer is, I think, entirely possible. Lots of keyframes, but probably not too terrible to implement. It might have to wait a few minutes, have to bone up on my 3D transforms to figure out how far each layer is from the camera, and not just in space. It would be nice to be able to apply things like fog and DOF and such.

And, not to put another thing in front of LM (okay, I am) but I wonder if this might be something that could be implemented in the renderer. everything else is there,only need to convert all the colors to gray by Z. Just asking.

So, kdiddy, have you got any working results to show from the Maya script? I'm curious what it'll get used on. I gotta put all this stuff up on my site with a nice little donate button. Even though I find trying to figure this stuff out ridiculously interesting (dunno why) I have spent a bit of time on it I shoulda been making rent. Ah, whatthehell.

--Brian
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

I'm glad to hear I'm tickling your thinking bone.

I don't have anything worth showing for the Maya script yet. When I do, I'll be sure to give you a link for you to download and use on your site (no charge :wink: ). If it helps a scripting/animation genius make the rent, then I'm all for it!
Post Reply