Unity Community


Results 1 to 11 of 11

  1. Location
    Germany
    Posts
    34

    Making lightmaps in Maya (tutorial)

    Since all the info on creating lightmaps is scattered through numerous threads in this forum and partially broken i decided to make a small tutorial and separate thread for all those who seek comprehensive info on the topic. So here we go:

    How to make lightmaps in Maya and bring them into Unity:

    DISCLAIMER: All the following is based on my (limited) experience and skill in both Maya and Unity. Though i still hope this small tutorial may be usefull to some. All feedback to make this guide better is ofcourse welcome.

    -- IN MAYA --

    1) Model whatever you want to light, add textures and materials to your objects as you normally would:



    2) Light the scene and render it with Mental Ray until you like it:



    3) Select and "Mesh->Combine" all geometry
    4) With the freshly combined Object still selected open the "Create UVs->Automatic Mapping" properties dialog and use these settings, then click apply:

    Code:  
    1. Planes: 6
    2. Optimize for: Fewer Pieces
    3. Shell Layout: Into Square
    4. Scale Mode: Uniform // IMPORTANT to get clean maps
    5. Shell Stacking: Shape // IMPORTANT to make best use of the available resolution
    6. Percentage Space: 0.2000 // IMPORTANT to have enough room for the bleed areas
    7. Create new UV set: checked // IMPORTANT
    8. UV set name: Lightmap // IMPORTANT

    5) Open the "Window->UV Texture Editor" to check out your new UV map you're gonna use to bake lights:



    6) Switch to "Rendering" toolbars and make sure you have your object still selected
    7) Open the "Texture/Lighting->Batch Bake(mental ray)" properties dialog and use the following settings, then click "Convert and close":

    Code:  
    1. Objects to bake: Selected
    2. Bake to: Texture // IMPORTANT
    3. Bake shadows: checked // IMPORTANT
    4. Keep original shading network: checked // IMPORTANT
    5. Use bake set override: checked // IMPORTANT
    6. Color mode: light and color // IMPORTANT
    7. Normal direction: surface front // IMPORTANT
    8. Prefix: myLightmap // IMPORTANT this will be the filename of the lightmap TIFF, pick a name you like
    9. X resolution: 2048 // depends on the size of the object usually 2048 is plenty, try various values
    10. Y resolution: same value as "X resolution"
    11. File format: TIFF // others work to as long as Unity can import them
    12. Bits per channel: 8 bits // IMPORTANT
    13. Number of samples: 1
    14. Bake to one map: checked // IMPORTANT
    15. UV range: Normal [0 to 1] // IMPORTANT, other settings lead to distorted maps
    16. Fill texture seams: 3 // IMPORTANT, this is the bleed area in pixels around each UV shape to avoid jaggy edges later in Unity
    17. Override mesh UV assignments: checked
    18. UV set name: Lightmap

    8) Maya will now render the lightmap into a texture (this may take a long time depending on the resolution settings and render options you used) and create a file using the prefix you specified. The lightmap will NOT display in Maya. The file will look something like this:



    9) Save your scene and ...

    -- SWITCH TO UNITY --

    ... import it to Unity
    10) Locate the lightmap ( default: /user/[your username]/documents/maya/projects/[maya project name]/renderData/mentalray/lightMap/[prefix].tiff and import it
    11) Place the Object in a Scene and select it
    12) Change all materials associated with the Object to "Lightmapped" and apply the .tiff file we just imported as lightmap
    13) Done, enjoy.



    Hope this helps. Some more details can be harvested in this thread: http://forum.unity3d.com/viewtopic.php?p=66440


  2. Location
    Capitol City New Zealand
    Posts
    3,191
    Nice work! This will be helpful.

    The only trick I learned as well, was to rightclick over the geometry, select UV Linking, and in the box that appears, select the UV in the left, and the corresponding filetexture in the right, and just by doing so assignes the file texture to the correct UV set.>Save...Open Unity>Do Cool stuff

    Good Stuff Gerold!
    AC


  3. Posts
    446
    Yes. Thanks much!

  4. Volunteer Moderator



    Location
    Copenhagen
    Posts
    5,299
    Nice work GeroldS, goes through most of the process. The only problem is you combine meshes with separate materials. Combining meshes and calculating the Lightmap is great, but you then need to separate these meshes that don't use the same material... you can then assign the lightmap to each one of these objects in the secondary UV channel.

    Creating 2 UV channels is the key and UT will hopefully be coming out with a full tutorial of this process in the near future... I created one for the Unity Magazine, but now it will probably be integrated into a future Unity tutorial.

    Ethan


  5. Location
    Portland, Oregon
    Posts
    1,157
    Did AT's tutorial ever appear anywhere?


  6. Location
    Ottawa Canada
    Posts
    1
    awesome place to start! I will add a few suggestions to cover any questions someone might have though

    first:

    if you want to brighten up the shadowed sections.

    before baking out the map, create an ambient light in your scene, it will tone down the shadow a bit (you cant really tell in his example, but once you start to have textures it becomes more apparent and you lose all diffuse to a pitch black shadow)

    brighter you set the ambient, less pronounced your shadows become



    second:

    there is a way to bake all your texture to a single texture using this technique, with some modification

    create your other UV set, and instead of baking shadows you disable that setting, and make sure the only lights you have in your scene is an ambient light, so everything is flat shaded, now you can bake out the "light and color" option and set the name as "texture" or something obvious.

    now you can copy the UV map from your lightmap UV channel to your map01 channel ( i suggest duplicating your original just incase )

    hope this helps!

  7. tz tz is offline

    Posts
    75
    I may be mistaken about what you were trying to do, but I believe if you're going to mix diffuse maps and lightmaps, you'll want to set the bakeset setting for color mode to 'light' only, as opposed to 'color and light', otherwise your lightmaps will get the diffuse texture map baked into them. This is fine if you have non-tiling textures and want to do a single texture, but if you're going to use the lightmap-diffuse shader in Unity, I believe you'll end up doubling up your diffuse pass.

    One further note that could trip people up. If your UVs don't come into Unity looking the way they do in Maya, one of the first things to do is to try deleting your construction history. Maya may be fine displaying UVs that are an aggregate of operations, but the history portion will be lost when brought into Unity.

  8. Asset Store Manager



    Location
    Unity HQ - San Francisco
    Posts
    375
    Quote Originally Posted by Tz
    I may be mistaken about what you were trying to do, but I believe if you're going to mix diffuse maps and lightmaps, you'll want to set the bakeset setting for color mode to 'light' only, as opposed to 'color and light', otherwise your lightmaps will get the diffuse texture map baked into them.
    Yes, you are absolutely correct, I just discovered that myself.

    As TZ just said, be sure to set the bakeset to LIGHT and not "color and light"

    That little oversight aside, GeraldS THANK YOU for this extremely useful and informative tutorial! It has made my life a little bit easier today.

    Caitlyn Meeks
    Asset Store Manager
    Unity Technologies

    http://unity3d.com
    http://blogs.unity3d.com


  9. Posts
    12

    Multiple UV sets ...

    Ok,

    Thanks for all the helpful information in this and other threads regarding the lightmap process. The demo above is excellent and I have the Unity portion down, but I'm failing to successfully set up 2 UV's out of Maya.

    Once I combine all of the objects to create a new Auto generated UV map, what do I do with it then? Does it then permanently replace my individual items or is it simply used to create the entire-scene lightmap. If it's the later and I am to discard the combined object, then how do I retain the UV map from that combined set.

    I'm missing something simple in all this, but for the life of me I can't seem to figure it out. Any help would be *greatly* appreciated,

    Q


  10. Location
    Online
    Posts
    147
    ive tried this tutorial and works great on my iphone project, finally after several years i know how to bake shadows in Maya

    i discovered a trick also for bake ambient light, first i tried with camera color enviroment and didnt work, then with mental ray enviroment sky and didnt work, finally the solution was to create a big sphere covering all the level with inverted normals (normals facing the center of the sphere) and add a material with incandescende, this means the sphere will emit light in the normals direction,
    that create a cool GI effect on my level

    i dont know if this is the best solution to create a GI effect thought it worked ok for me

    hope this helps


  11. Location
    Girona, Spain
    Posts
    14

    Lightmap Texture problem

    Hello I've some problem with the generated texture. (see picture)

    Any body knows how to fix it?

    Thank you![/img]
    Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •