Search Unity

[Maya Mac] External Lightmapping Tool

Discussion in 'Formats & External Tools' started by ranza, Jan 17, 2010.

  1. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    Hi!
    After releasing ELT, Unity and I decided to extend the system to Maya, so that both Mac and Windows users can make nice lightmaps for their scenes.

    Right now there are still a few things missing, but the rendering is working (should work) on both Mac and PC.

    The thing that I'm lucking is the real knowledge how Maya works, so I'm asking you dear Unity Community Members for a little feedback and suggestions.
    I'll be happy to implement whatevers needed ;)

    Below is the latest version [updated]
     

    Attached Files:

  2. giyomu

    giyomu

    Joined:
    Oct 6, 2008
    Posts:
    1,094
    hey pretty cool , thanks for that , I am going to have a try at it ;)
     
  3. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Does this file is supposed to run under Maya?

    - maxscriptEngine.ms


    Also a readme.txt file is welcome to understand where we have to drop your directories etc...

    All noobs don't really know they have close Maya, to drop the "LightmappingTools" directory in their MayaXXX/Script directory, to launch Maya and then using the following command in the mel script editor:
    Code (csharp):
    1.  
    2. source "LightmappingTools/melEngine.mel";
    3. BatchBake ();

    To tell the truth I am not fan of global variable...
    Because if I install 10 melscripts with 3 global variable as your script, Maya wouldn't be happy after each reboots :(
    My advise could be to create an empty node and to attach all attributes you want on it and then you can query them when you want it and they will stay in the current scene as preferences, etc...


    ...and l-34 :

    Code (csharp):
    1.     image -w 170 -h 60 -image "F:/Lightmapping Tool - Working/Assets/LightmappingTools/logo2.png";
    2.  
    There is call to a picture from your path directory and not the Script directory.
    It creates a double error! :eek:


    For a test I created a new scene with a cube and simple plane. I combine the 2 objects, clean the history, optimize scene size.
    I change the name of my object to "A".
    Also save my current scene under "test.ma".

    I select the object and click on the "Bake all now"!

    And I get this message :

    Code (csharp):
    1.  
    2. At 0 we try to bake A
    3. // Warning: file: XXXXXXXXXXXXXXXX/2009-x64/scripts/LightmappingTools/melEngine.mel line 172: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    This is only a warning , not an error, but after that there is nothing else then I do not know what it supposed happen next! :?



    Scripts look interesting, then I wait for more debug on the tools :p :wink:


    EDIT :

    After deleting the Logo line I got this error too :

    Code (csharp):
    1. // Error: file: XXXXXXXXXXXXXXXX/2009-x64/scripts/LightmappingTools/melEngine.mel line 85: Cannot find procedure "miCreateDefaultNodes". //
    2.  
    I'm running under Window 7-64 and Maya 2009-64.
     
  4. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    Thanks for pointing the mistake with the path. It was 'hard coded' and I forgot to change it.
    It also seems that I've gave too less information.

    1. You're not suppose to move the scripts anywhere, the system loads maya automaticly with the appropriate scripts
    2. You can check how to use it here: http://masteranza.wordpress.com/unity/lightmapping/
    (It's the already done part for 3dsmax - but works very similar)


    I've done a post on my blog about this:
    http://masteranza.wordpress.com/2010/01/18/lightmapping-tool-for-maya-and-mac-alpha/
     
  5. WinningGuy

    WinningGuy

    Joined:
    Aug 10, 2009
    Posts:
    884
    There are a bunch of Maya experts that also hang out at cgsociety.org and techartists.org that could probably help.

    If you find that you still need more help, you could also post there.
     
  6. ng.aniki

    ng.aniki

    Joined:
    Jan 6, 2010
    Posts:
    3
    Hi ! And thank you for you work, I was waiting for a Maya version of your tool !


    I tried to use it, but Maya gave me some errors...
    I understand it is an alpha/beta, so, here are my logs, it may help you:

    When I try do bake the lightmaps of a selected mesh, I receive this:

    Code (csharp):
    1. At 0 we try to bake ImportedObject1
    2. convertLightmapSetup -camera persp -sh -bakeSetOverride BakeSett -ulb -keepOrgSG;
    3. // Error: Cannot find procedure "convertLightmapSetup". //
    And when I try to bake all, the errors are:

    Code (csharp):
    1. At 0 we try to bake ImportedLight1
    2. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    3.  
    4. At 1 we try to bake ImportedLight2
    5. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    6.  
    7. At 2 we try to bake ImportedLight3
    8. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    9.  
    10. At 3 we try to bake ImportedLight4
    11. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    12.  
    13. At 4 we try to bake ImportedLight5
    14. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    15.  
    16. At 5 we try to bake ImportedLight6
    17. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    18.  
    19. At 6 we try to bake ImportedLight7
    20. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    21.  
    22. At 7 we try to bake ImportedLight8
    23. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    24.  
    25. At 8 we try to bake ImportedLight9
    26. // Warning: file: C:\Users\Public\Documents\Unity Projects\Hangar\MaxFiles\MainScene2_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    27.  
    28. At 9 we try to bake ImportedLight10
    29. // Error: Invalid negative index used to reference array "$resArray". //
    30. // Error: Error evaluating argument at position 1 in procedure "makeBakeNode". //

    I am using Maya2010 on Windows7 x64.
    Keep up the good work ! :D
     
  7. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    Thank you ng.aniki, I think it should be fixed right now.
     
  8. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I am just trying a test scene of my own, with four boxes and a Unity light, after exporting from Unity to Max 2010 the light shows up in Max but the objects do not, well in the Select From Scene dialog in Max it does show Imported Object01 but the scene objects are not visible in the viewport. I render the lightmap and get an all white texture with no shadows.
     
  9. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    hi Don,
    this may not be the best place to explain this since it's rather connected with primary version of the elt.
    However, first of all try to focus on that object using Z shortcut inside 3dsmax if you've done so and no objects are appearing then contact me at over skype - username: masteranza
    or mail: masteranza at gmail dot com
     
  10. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Ok, email sent.
     
  11. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Hi ranza, I tried to use the ELT with Maya export. But it is not working.
    Basically I was testing with very simple unity scene, the scene has just the a cube, sphere, plane and a light (primitives created in Maya).
    The problem is after the Maya launched, it has no mesh that have been imported inside Maya at all.(just a empty scene in Maya)

    I tried to click the button "Reimport scene manually" from the ELT window, nothing happen.

    Error in Maya Script Editor:
    Code (csharp):
    1. # Error: No module named timer
    2. # Traceback (most recent call last):
    3. #   File "<maya console>", line 1, in <module>
    4. # ImportError: No module named timer #
    5. // File read in 0 seconds.
    6. Mental Ray set!
    7. # Error: No module named timer
    8. # Traceback (most recent call last):
    9. #   File "<maya console>", line 1, in <module>
    10. # ImportError: No module named timer #
    Something wrong with "No module named timer",and I noticed inside the startup.mel, line 228, about "import timer;".

    Code (csharp):
    1. global proc startTimer(int $runTime, string $command)
    2. {
    3.     python("import timer;"
    4.         +"timer.startTimerObj( " + $runTime + ", \"" + encodeString($command) + "\")");
    5.  
    6. }
    My System Spec:
    Window XP Professional
    Unity 2.6.1
    Maya 2008

    I tried to switch the same simple scene that export to Max 2009, it works just fine as expected.

    I'm wondering that I have an old version of Maya 2008 cause that problem or not?
     
  12. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    Thank you for your feedback LuckyMouse, it's very helpful!
    What it tells me is that either
    the defualt import path isn't equal to script home directory
    or there is no possibility to do import a module in maya2008
    or timer.py module is not in your Assets/LightmappingTool directory.

    If timer.py module is in your Assets/LightmappingTool directory, please try to copy it to maya defualt script dir, which in most cases is:
    "My documents\maya\scripts"

    If this won't work then try to copy it to some other directory where maya holds scripts, like
    "C:\Program Files (x86)\Autodesk\Maya\Python\lib\site-packages\maya"

    I don't have maya2008, if you'll make it work, please write me - we'll make a notice for others.


    For all new readers of this topic:
    ELT for Maya&Mac has been added to regular ELT available on my blog: http://masteranza.wordpress.com/unity/lightmapping/
     
  13. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    The python script timer.py is in Asset/LightmappingTools folder. For some reason Maya did not source that script. Anyway, I copied timer.py to "My documents\maya\scripts" folder, and It works! I see the imported meshes in Maya now :D

    The timer module is fixed. However, I got another error after clicked the "Bake all now!" button.

    Error code in Maya Script Editor:
    Code (csharp):
    1. At 0 we try to bake ImportedLight1
    2. // Warning: file: D:\Michael\Desktop\00001\MaxFiles\001_startup.mel line 197: Starting position (15) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range. //
    3.  
    4. At 1 we try to bake ImportedObject1
    5. convertLightmap -camera persp -sh -bakeSetOverride BakeSett -ulb -keepOrgSG;
    6. // Error: Invalid flag: -ulb //
    7. // Error: (Mayatomr) : at least one shading group and one dag object expected, command not executed //
    I got the similar Error as previous Post from ng.anik
     
  14. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Thanks for supporting!. As you said in the email that I changed convertLightmap to convertLightmapSetup in the Mel script. Maya will do the Lightmap rendering now :D
    I know it is just an alpha version, for now I guess i can just use it and ignore the warnings.

    Great job! 8)
     
  15. ytinu

    ytinu

    Joined:
    Oct 23, 2009
    Posts:
    34
    Hi-

    Thanks for this great tool!

    I have been trying to find a tool to export a unity scene to maya for light mapping - and this seems to fit the bill.

    However - please excuse my Newbe with this.. but when I place the files in to the "unity\Assets\Lightmaps" folder then run the "windows/external lightmaping tool" in unity-
    the window comes up - I select a mesh and add it (and its red) so I add a lightmapping shader - and click export - however nothing happens.. Also on your vemo video it looks like you have a button under you model that lets you export the scene to Maya.. this as well I dont see.

    I am on a PC running windows Vista x64 - unity Pro trying to export to Maya 2009 x64

    Great idea tho - I wish you Success !
    Cheers
    T~