PDA

View Full Version : Creating Physical Sun and Sky through mel


TheBeals
05-31-2009, 08:20 AM
Hey everybody, I am trying to work on a mel script that will render a wireframe render in MR using the sun and sky as the lighting source. I use:

miCreateSunSky;

to create it.But it doesn't do this and it gives an error: // Error: Cannot find procedure "miCreateSunSky".

However, if I were to manual create it by clicking the button in Globals (I'm running 2009), and then delete it and run the (miCreateSunSky;) script it turns it on and renders perfectly.

So I guess simply put, How do I create the Physical Sun and sky through Mel? It is the only part of the script so far that is giving me trouble and I haven't been able to find an answer through fellow friends. Any ideas?

~Cheers

Jonathan Beals
http://jdbeals.com/
Modeling, Lighting, Texturing

Hirni_NG
05-31-2009, 02:23 PM
Unfortunately miCreateSunSky; is defined within the GUI, specifically in createMentalRayIndirectLightingTab.mel and is dependent on GUI nodes. So the command will not be defined until the Tab GUI script is called. You cannot call thecreateMentalRayIndirectLightingTab.mel yourself.

What you need to do is creating the nodes yourself directly, if you create SunSky and look in the Hypergraph what kind of nodes have been created, this is what you need to create by yourself.(There is quite a bunch, physicalsky, physicalsun, exposure node, connected to MR nodes etc....).

You can either create that all by hand or you export the relevant nodes and connections and import that node structure. You can also look at the exported .ma and create your own script from that.

Depending on the context of your script, there may be problems concerning the GUI or other dependencies.

djx
05-31-2009, 02:36 PM
I agree with what Hirni_NG wrote. However I'd add that a good source for the mel you need is the createMentalRayIndirectLightingTab.mel and in particular the miCreateSunSky proc. You can copy and paste what you need from there to make your own mel script.

-- David

geoff3dnz
06-01-2009, 01:37 AM
One problem I run into is that until the Indirect Lighting tab in the render settings panel is viewed, Maya doesn't seem to know what mentalrayGlobals.imageBasedLighting is, so you can't recreate that connection:
(iblNode.message --> mentalrayGlobals.imageBasedLighting).

Mental Ray is (auto)loaded at startup, and I have "buildDeferredMenus();" in my userStartup.mel (which I assumed sort of auto-loaded GUI menus for such uses as this)... maybe not.

djx
06-01-2009, 05:48 AM
iblNode.message --> mentalrayGlobals.imageBasedLighting
Why do you need that connection?
I'm not implying that you dont. I am interested to know what it actually is used for.

-- David

TheBeals
06-01-2009, 06:27 AM
Ahhh yes, that indirect lighting tab is giving me quite the slew of problems with not being able to load attributes within that tab and giving me plenty of wonderful errors unless I open the tab manually.

So far I am able to use the createMentalRayIndirectLightingTab.mel to create the tab as well as the Sun and Sky and set whatever attributes I want. It still gives me odd warnings here and there. And all other tabs go away, but if I switch to software and then back to MR, they all return hapily and all my settings are still saved. This sure is alot of code just to get a lighting setup haha... crazy GUI not letting me do what I want to easily. Here I thought it would be fairly straightforward.... silly me.

geoff3dnz
06-01-2009, 06:36 AM
Why do you need that connection?
I'm not implying that you dont. I am interested to know what it actually is used for.

-- DavidIt hooks up the IBL Node to mentalray so that it actually sees the IBL for Final Gather etc (and hooks it up into the IBL section of the render settings panel)... although of course, none of the mentalray globals are available (turning on Final Gather for example) until you open up the render settings panel and move to the indirect lighting tab, so it's all a bit moot. I can't get seem to script any of the mental ray stuff starting from a fresh empty scene.

geoff3dnz
06-01-2009, 06:52 AM
Ah embarrassment ;)
Had I scrolled down to the very bottom of the createMentalRayIndirectLightingTab.mel I would have seen the magical command:

miCreateDefaultNodes();

It appears that so long as you run that first in your script, all the nodes are there to connect into without having to open the render settings panel.

TheBeals
06-03-2009, 06:36 AM
w00t. So the script is moving along after a few days on hiatus.
I'm able to create the render global nodes, but I have to still create the indirect lighting tab and update it so when I create the physical sun and sky it can connect to that button. The only problem is, it's delete the other tabs, so I just need to figure how to get the other tabs back, refreshing, updating, or reverting...somehow and it will be nearly finished. I've been looking through the RenderGlobals scripts, but no luck-just yet. Any thoughts/ ideas?
Thanks for all the help, I really appreciate it.

Jonathan Beals

royg
06-03-2009, 06:59 AM
w00t. So the script is moving along after a few days on hiatus.
I'm able to create the render global nodes, but I have to still create the indirect lighting tab and update it so when I create the physical sun and sky it can connect to that button. The only problem is, it's delete the other tabs, so I just need to figure how to get the other tabs back, refreshing, updating, or reverting...somehow and it will be nearly finished. I've been looking through the RenderGlobals scripts, but no luck-just yet. Any thoughts/ ideas?
Thanks for all the help, I really appreciate it.

Jonathan BealsDid you read the post directly above yours?

TheBeals
06-03-2009, 07:04 AM
Aye, I did. If I type that in, then create the physical sun and sky nodes, it still can't find the output node to connect the skyshader to which is in the indirect lighting tab.

triptych79
11-10-2009, 02:06 AM
Did you get any further with this script?

I have the same issue where I want to query the mentalrayGlobals.imageBasedLighting connection without manually having the operator open the globals and click on the indirect illumination tab first. I want this to occur upon starting Maya up.

This was possible in Maya 2008 but it is somewhat frustrating to achieve in the later versions.

Any help would be greatly appreciated.

Cheers

BTW, miCreateDefaultNodes(); doesn't work 100%, especially when you try and query mentalrayGlobals.imageBasedLighting upon starting Maya up.

royg
11-10-2009, 02:44 AM
*** CONTENT REMOVED ***

TheBeals
11-11-2009, 07:32 AM
nah, I never was able to. I ended up doing what you said you had to do. I agree it was much easier to do it previous versions, but I can't figure it out for the life of me in 2009. If you ever figure it out, post your solution, I would love to hear it! GL!
~Cheers

CGTalk Moderation
11-11-2009, 07:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.