Sunday, February 12, 2012

MetaSL Merge Node

I've wanted more blending modes for the maya hypershade for about as long as I could remember, when I started using Nuke for compositing last semester this desire became even greater. I let this bubble around for months never having adequate time to research creating custom nodes for maya and mental ray. Then one day over christmas break while learning some basic CGFX shader programming and seeking for a way to create custom shaders for mental ray, I stumbled upon MetaSL (linked below). Turns out that it's possible to create a mental ray phenomenon (djx is awesome) and load a MetaSL shader directly into maya for rendering. I started out by writing a basic lambert shader then thought I'd try my hand at implementing all the blending modes from the Nuke Merge node using MetaSL.

It turned out to be a lot easier than I had expected, especially after finding a great resource that included the math behind photoshop blending modes. Of course the beauty of the Nuke merge node is that it brings alpha channels into these equations (oh yeah). The idea of combining shaders using the Nuke merge node just became more and more tantalizing. Luckily a tooltip inside Nuke shows the basic equations they use!!

There are catches OF COURSE, it was all a little too good to be true. It turns out that this implementation does not work on shaders at all, and why should it, after all, the outputs of mental ray and maya shaders are complex and varied.  I was pleased, however, that the phenomenon and MetaSL shader works on textures and color swatches, although plugging these textures into a typical shader yields unstable results and often crashes maya when rendering in mental ray.

 I may be able to tweak the phenomenon to pass the proper elements from shaders to the MetaSL shader, but, I'm not sure it's worth the time. I'll probably do some more research and use a more typical method of creating custom maya nodes. If I get any free time I will absolutely get this done, a proper merge node supporting alphas would be indispensable in creating custom shaders.

Here are a few screenshots anyway!






























I'm including the MetaSL shader and phenomenon in case anyone would like to take a look, I'm calling it dbr_merge.


Resources:
dunnybypaul.net (photoshop blending modes)
djx - exploring mental ray phenomenon
MetaSL

No comments:

Post a Comment