Hooked on MEL

Ah yes some of the chaos from my recent move is mellowing out.  Anyways, I've been hearing for years that being able to script in Maya is the shiznite and I totally believe it, I just didn't think I was the script minded type. But recently, I finally got a real “what the hell, why not” moment and decided to jump into MEL, I wanted to make something practical [but simple of course].My goal was to make a script that would create a 35mm render camera with a dark gray gate mask, film pivot, film origin and also slap an mia_exposure_photographic lens with a Cm2 factor of 100000 on it.  Doing this manually is easy but just a bit “click intensive” for what it is, so it just becomes tedious.  That in itself was surprisingly easy to script [the node and command ref in the help docs kick ass] but that snowballed into “Why not make a camera with aim instead?” and then  “hmmm I wonder if I can slap a bokeh lens shader on that too” then that quickly turned into “Hey, I bet can setup a distance measurement and feed that into  the bokeh lens shader” [Also  I'm really leaning towards having the script detect the physical sky [if there is one] and plug that into the environment slot of the camera.]That worked but the generic names would become a problem so I decided to make a simple interface with a name input field and a “Create” button and that turned me onto the magical world of global procedures and variables.

Ok so the interface has a looooong way to go but for now its good enough for testing.









 I made the distance locator independent of the aim, as it allows getting different values without screwing with the aiming of the camera.






































Exposure lens shader.





























































This inspired me to go for gold!  And one of the  issues I was having was dealing with gamma hurdles in the linear lighting workflow.  Previously, I had a “pre-corrected” mia_material_x tucked away in a hypershade tab that I'd  right click import on demand but that doesn't do much if you have a shader networked already.  So I decided to make my own script that will  de-gamma all color slots on my shader.  I'm in the process of creating some brother and sister scripts that accompany it to deal with lights and some quicky render presets buttons and they will be accessed via an interface of my making :3.  My Hubby calls it the poor man's Maxwell lol so I decided to call it “PMM”.  There is a gamma correct all script in the works as well.So far the “PMM_deGammaOne” script works![I'm so excited ^^] and this is what it does:

__

-  Checks the type of shader I have selected, if its not an mia_material type,  my juicy error message pops up.  If not then it'll...

-  Checks the shader's color channels for textures , textures it finds will be run through a gamma node and those will be plugged into the shader.   If there is just a color swatch instead, it grabs the color information and uses that for the gamma node's value.  Then the gamma node is plugged into the shader.

-  Creates a lambert shader, a mule and plug the mia_material into its shading group [why do I do this?  Because they are good realtime stand-ins.]

-  Changes the lambert's color to whatever texture or color the mia_material diffuse channel was using.

-  If there is a texture in the mia_material's cutout opacity slot, then that texture is ran through a reverse node and plugged into the mule's transparency channel.[Why the reverse node?  Because the mia cutout and maya transparency use black and white values in an opposite manner]


-  Then it does a bunch of renaming to make sure everything is on par with the mia_material [I was tired of having the shading group to my “oxidized copper” shader named “mia_material_x76SG” and the “gammaCorrect215” madness. This script solved that]


-  Then it goes on to assign the mule to the objects that are using the mia_material as a shader.


With this script, I can just create networks without even thinking about gamma nodes then just run it after or before whatever.  I would recommend learning a scripting language to anyone, as applications cannot be designed to suit everybody and being able to create your own tools and operations is pretty sweet, I'm just kicking myself in the arse for not jumping on this sooner!


Screenshots! :3

Bit of a nonsensical shader but it has textures in the diffuse, reflection color, cutout opacitiy and bump.


























And Bam!













































However, I am going to change the naming convention to use the node name as a prefix on the gamma instead of the shader name as "gamma" isn't even shown because of the long shader name in this instance.



























I keep breaking the script adding new features lol but its all in the name of fun ^^


And this image is the result of the using not just the camera and  the shader de-gamma but also one I made for lights.

2 comments:

  1. tat certainly helps speed up the linear workflow process. also, renaming all the nodes makes it a great hypershade organization tool.

    ReplyDelete
  2. Yeah it does help A LOT, still tweaking it though :o

    ReplyDelete

Leave a message at the beep...wait for it...:p