Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

3dsmax lightmap small tutorial

Discussion in 'Import Formats & External Tools' started by 3dmaxter, May 17, 2009.

  1. 3dmaxter


    May 16, 2009
    Hello. I just wanna share my way on doing Lightmap in 3dsmax to unity. I read many post asking how to do this, and I want to share with all of you. Please tell me if there is a better way.

    1. When you finish uvw your model save it to .uvw file

    2. Create new uvw and change it to channel 2. Load the uvw you created earlier. This give you better result than using automatic uvw.

    3. hit (0) to open the render to texture window. Select "Use Existing Channel", change the Channel to "2", choose add "Lightingmap".

    The image you see when rendering is not the real result. The real image was stored in your 3dsmax folder. usually it stored like this (My Documents/3dsmax/sceneassets/images) look for your model name with "LightingMap" on the back. Usually a TGA file like this.

    4. The easier way is to "Pick Material from Object" and then copy the "Baked Material" to an empty slot. Because .fbx exporter currently doesn't support "Shell Material".

    5. After you assign the new baked material to the model, export the model with fbx extension. Here I use cm, embed textures, convert to portable format (TIFF).

    6. When you open your unity project, and Import the model, you will see it's only the diffuse texture that was exported from 3dsmax. And no LightMap texture. My way is to import the LightMap texture that 3dsmax stored in (My Documents/3dsmax/sceneassets/images). And then add it into fbm folder of your model.

    7. After that done. Change your model material to a Lightmapped material. And add the Lightmap texture into the slot.


    Next I will update the post with "uvw tilling model lightmapped" :D
  2. antenna-tree


    Oct 30, 2005
    Good stuff! Adding to the FAQ ;)
  3. holmeren


    Dec 12, 2006
    Good and simple, nice one...

    One little note:
    Max 2009 has become quite unstable in its UVs when working with more than one UV. So its a VERY good idea to save ALL your UVs just as you save textures and models.

    You could, in your "Render To Textures" settings, set your render to not use Shell Mat. and then choose the baked texture to be applied to your Diffuse instead of the Shell Mat.

    But hey its minor!

  4. 3dmaxter


    May 16, 2009
    Hi guys, sorry for the delay hehe, the world keep me busy this whole week XD

    Wow Thank you aNTeNNa trEE for putting my thread on the FAQ ^^

    "Here it is!! Lightmap with tilling textures"

    First let me explain, I am using 2 different way of using Lightmap for this one. You know why later on.

    1. Here I have 2 objects (interior, and sofa). I highlighted the texture so you can see them clearly. There are 8 textures (7 for interior and 1 for sofa).

    2. Unwrap UVW set (ch 1) hit save.

    3. Unwrap UVW set (ch 2) load from the first channel.

    4. In Baked Material option, choose "Output into Source" and "Keep Baked Materials". This option will automatically update your original material without using a shell material again. Thanks to holmeren for the update ^^. Hit (0) for render to texture window.

    --> result

    5. Repeat the process for the sofa. (Explained on top of this page).

    Hit M to and see your new baked material (Check it out! the "Self Illumination Slot" is now containing the Lighting Map texture.

    6. Export to FBX

    7. Open Unity and import the asset. Because in 3dsmax we use 8 texture for the model, so unity will assign them into 8 materials. As usual the lightmap textures aren't exported along with them.

    Import manually the lightmap texture from your 3dsmax folder (MyDocuments/3dsmax/sceneassets/images) look for your model name with LightingMap on the back.

    In this case I have 2 (sofaLightingMap.TGA, and wallLightingMap.TGA).

    8. With all our texture assembled, we are now ready to change the default material into "Lightmapped" material. I choose Lighmapped/VertexLit. Assign the correct lightmap texture to the correct material model.

    Yess!! The Lightmap placed correctly.

    9. Time to "tilling" our interior textures.

    Yes!! Finish!!


    What if I want to use non tilling texture along with the tilling textures? Well I came across some error in exporting as well but I found a way to get that done.

    <Different solution>

    1. The uvw I use is the same as before. Only this time with different texture for the wall.

    (1 for the wall, 1 for the floor, and 1 for the sofa).

    The wall texture

    2. Exporting as usual.

    3. Import them into Unity and change the diffuse material to Lightmapped material.

    4. Apply the Lightmap texture, and tile only the floor texture.

    5. Finish!!


    Conclusion...and problems

    First method:

    We will have lot of material in our mesh because we assign a lot of different texture in one model. Smaller textures but with sharper image, thanks to the tilling system. Add 30 kb.Mat

    Second method:

    We use less material and less texture, but with bigger resolution (my custom texture wall have 512x512 resolution). Add 11 kb .Mat

    I don't know the performance difference between those two. So if anyone can share your opinion, I'd be most grateful.

    So that finished my small lighting map tutorial.

    Good Luck on your project, (mine too hehe) and Thank you very much to Unity3D team. Cheers.
  5. holmeren


    Dec 12, 2006
    Sweet as candy!

  6. hike1


    Sep 6, 2009

    Attached Files:

  7. designxtek


    Mar 13, 2009
    I've been trying out different methods of light mapping and this is the most helpful tutorial I've seen so far! Thanks!
  8. designxtek


    Mar 13, 2009
    I just tried a test. For some reason I can't get all of the sub materials to export. It only exports as one. I used the multi/sub object material with 2 materials


    I got it.

    Before I was setting each object on its own g-buffer channel. Didn't work.

    I combined everything into one mesh and selected each face and applied "material modifier" to it and set the material id from there.

    When I exported I got individual materials.

    Now the walk through will make more sense =d
  9. 3dmaxter


    May 16, 2009
    sorry i haven't online much, can you describe the problem? or can you upload the max file again? it's seems the link is not working. I presume your secondary uv is not render correctly.

    Sometimes different model needs different approach. Like when you share same texture on different material, you are most likely to choose "Material Generation - Per Material". An object with lightmap is more likely using "Per Material" setting.
  10. designxtek


    Mar 13, 2009

    Thanks to light map I got my level light mapped done. It looks awesome!
  11. spoof


    Feb 14, 2010
  12. Sinnlos


    Mar 23, 2009
    i've got one question:
    why do you add a second map channel?

    it has the same information like the first, so why have two?

  13. Bryan A

    Bryan A

    Feb 9, 2010
    Because that's how Lightmap shader in Unity works. It detects the second UV channel as the model Lightmap UV coordinate. No need to properly Unwarp the model nicely for the Lightmap channel. A good flatten UV would suffice.

    Nice tutorial by the way.
  14. Marv34


    May 7, 2010
    Hey thanks for the some of these work arounds. I'm having an issue with Light maps trying to reuse each other. Say I have a couch with Brass legs and then a Brass Railing. I can get the diffuse mapping to work correct, but when I go to apply the individual light maps, It will use the either the rail light map on both Couch brass leg and Brass hand there a way to fix this. Maybe something I'm missing here. :?
  15. badoli


    Aug 11, 2009
    Hey, i tried that workflow, but for some reason i just don't get the same results. The FBX i export from 3D Studio Max isn't imported into unity the way i intended. Unity seems to ignore the second UV-Set, the one for the lightmaps. I checked the FBX-Files, when i export them as ASCII, they contain the second UV-Set and 3D Studio Max also imports it the correct way again. Yet in Unity it turns out wrong!

    Here the Model in Max:

    This is it with only the lightmap:

    In a quick render, you can see that everything is working in Max:

    But imported into Unity, it is broken:

    In this excerpt of the ASCII-FBX, you can see that the uv-set is properly exported (i tried binary aswell as ASCII, nothing works!):

    Code (csharp):
    1. Texture: "Texture::windowFramePainted_DIF", "" {
    2.         Type: "TextureVideoClip"
    3.         Version: 202
    4.         TextureName: "Texture::windowFramePainted_DIF"
    5.         Properties60:  {
    6.             Property: "TextureTypeUse", "enum", "",0
    7.             Property: "Texture alpha", "Number", "A+",1
    8.             Property: "CurrentMappingType", "enum", "",0
    9.             Property: "WrapModeU", "enum", "",0
    10.             Property: "WrapModeV", "enum", "",0
    11.             Property: "UVSwap", "bool", "",0
    12.             Property: "Translation", "Vector", "A+",0,0,0
    13.             Property: "Rotation", "Vector", "A+",0,0,0
    14.             Property: "Scaling", "Vector", "A+",1,1,1
    15.             Property: "TextureRotationPivot", "Vector3D", "",0,0,0
    16.             Property: "TextureScalingPivot", "Vector3D", "",0,0,0
    17.             Property: "UseMaterial", "bool", "",1
    18.             Property: "UseMipMap", "bool", "",0
    19.             Property: "CurrentTextureBlendMode", "enum", "",1
    20.             Property: "UVSet", "KString", "", "UVChannel_1"
    21.         }
    22.         Media: "Video::windowFramePainted_DIF"
    23.         FileName: "G:\Projects\Unity\textures\windowFramePainted.tga"
    24.         RelativeFilename: "windowFramePainted.tga"
    25.         ModelUVTranslation: 0,0
    26.         ModelUVScaling: 1,1
    27.         Texture_Alpha_Source: "None"
    28.         Cropping: 0,0,0,0
    29.     }
    30.     Texture: "Texture::cafeOstfluegel_LM_I", "" {
    31.         Type: "TextureVideoClip"
    32.         Version: 202
    33.         TextureName: "Texture::cafeOstfluegel_LM_I"
    34.         Properties60:  {
    35.             Property: "TextureTypeUse", "enum", "",0
    36.             Property: "Texture alpha", "Number", "A+",1
    37.             Property: "CurrentMappingType", "enum", "",0
    38.             Property: "WrapModeU", "enum", "",0
    39.             Property: "WrapModeV", "enum", "",0
    40.             Property: "UVSwap", "bool", "",0
    41.             Property: "Translation", "Vector", "A+",0,0,0
    42.             Property: "Rotation", "Vector", "A+",0,0,0
    43.             Property: "Scaling", "Vector", "A+",1,1,1
    44.             Property: "TextureRotationPivot", "Vector3D", "",0,0,0
    45.             Property: "TextureScalingPivot", "Vector3D", "",0,0,0
    46.             Property: "UseMaterial", "bool", "",1
    47.             Property: "UseMipMap", "bool", "",0
    48.             Property: "CurrentTextureBlendMode", "enum", "",1
    49.             Property: "UVSet", "KString", "", "UVChannel_2"
    50.         }
    51.         Media: "Video::cafeOstfluegel_LM_I"
    52.         FileName: "G:\Projects\Unity\textures\cafeOstfluegel_LM.tga"
    53.         RelativeFilename: "cafeOstfluegel_LM.tga"
    54.         ModelUVTranslation: 0,0
    55.         ModelUVScaling: 1,1
    56.         Texture_Alpha_Source: "None"
    57.         Cropping: 0,0,0,0
    58.     }
    What am i doing wrong...?!
  16. badoli


    Aug 11, 2009
    Oh, forget it. I just found the problem.

    Seems like 3D Studio Max screwed with its own meshes again. This time a major one, one of these very special "you will never find out what's wrong" problems that you cannot get around with the usual "convert to mesh and back to poly" or "add to another mesh to fix it" solutions (tried those aswell). I tried the most radical workaround and that one finally worked: After i imported the mesh from the FBX back into Max and then out again, Unity has no problems using the second UV-set... This stupid thing cost me a day to find out... AAAARG!
  17. mrinal


    Jan 11, 2011
    Nice tutorial. Thanks
  18. 3absiso


    Apr 16, 2010
    This Tutorial is the Best. it helped me alot
  19. Wildpepper


    Dec 15, 2009
    Hey there :)
    Thanks for the tutorial
    got me in the right direction too, some time ago.
    since i found pretty painful the manual lightmap assign operation, above all with large scenes, i've just published a tool that makes it pretty fast, for people with some attention to the naming convention :)

    It imports your baked Lightmaps
    and automatically assigns them to the matching object. optionally converting it's material
    (useful if you also want to switch from the default Diffuse to a Lightmapped one)
    You can also tweak the ambient color of selected objects.

    you can buy it here

    any feedback would be appreciated :)

    (sorry if i posted it in the wrong place, but anytime i searched for that feature, i stumbled in this post :)
    Last edited: Jan 28, 2011
  20. WideloadChris


    May 20, 2011
    Just out of curiosity, what drove all of you to use Max to generate lightmaps rather than using Unitys Beast lightmapper? Does it lack certain features or did you just find you ended up with a better result by doing it in Max? Just curious.
  21. k3D-Junkie


    Jun 14, 2011
    First off, I'm going to go out on a limb and guess that most of us baking our own lightmaps are probably using VRay. For an artists, all of the GI renderers are painful and overly technical to use. No matter which one you use, you tend to rack up a lot of hours just figuring out how to get the results you want- the last thing we want is to have to learn another. Not to mention that VRay is not cheap.

    VRay has been the renderer of choice for the architectural community for many years as it is fairly easy to get a very good result quickly, and even more importantly, easy to tweak to get just the look we want without having to know all the math behind it. Also, it is very fast. Plus you get the advantage of full control over the lights in max. Game engine lights are fairly limited.

    Probably the biggest reason is that designing the lighting solution isn't a one shot deal. So we are used to spending a lot of time experimenting with the viewport render before we even think about baking the textures into a complete map or a lightmap (for when you want to tile your diffuse map or dynamically change it during runtime).

    Beast has a lot of nice features, but without a massive time investment is more of a one shot solution- which is great for first person shooters other fast-paced games where the time spent on subtle lighting effects is probably not warranted. It takes more time to prep objects and re-create their materials in Unity, but to us, the result is well worth it for many types of realtime applications.

    just my 2 cents
  22. hippocoder


    Digital Ape Moderator

    Apr 11, 2010
    Using 3dsmax's default lighting model will yield significantly worse results than beast. But factor in mental ray or vray and you have lighting that is very good indeed. But it takes tremendous effort to get good results with those packages that would even beat beast's catch-all parameters.

    Some beast positives:

    1. you don't need vray or mental ray. Not everyone wants to use pirated software, and not everyone can afford 3dsmax, so technically max and maya users would be the minority. A guy using blender is going to get awesome results with beast.

    2. your lights in unity match the beast lighting so characters are correctly lit when they get closer and their shadows kind of drop off really nice.

    3. beast is easier to get acceptable results with and the automatic unwrapping can save a lot of heartache.

    4. the most important reason to use beast is as simple as this: it is inefficient to lightmap in max or maya. Simple as that. With beast you can drop many prefabs into the scene, and build complex levels in unity, and lightmap them there. Not only this, things can move after the lighting, like a tree swaying slightly. That wouldn't look too out of place, but the tree would be correctly lit. Beast lets us do this, where external lightmapping would pretty much require tonnes of re-lightmapping instead of just saving a scene with the same assets.

    There is one reason to use external packages in the lightmap chain and that is if you are generating your own lightmap coordinates for the geometry but letting unity's beast lightmap it (just not generate the uvs). There are a lot of combinations to try, but for my games, I will always be using beast.

    Because its faster to develop like that, than mess endlessly in modelling packages. Beast does give great results in a very quick fashion, and lets you make better games.

    Why does beast allow you to make better games? Let me explain: you could dump many walls and object prefabs down, hit lightmap and test. But what if during playtesting you decide that this object needs to be a few inches to the side? do you go into your modelling package, move it, re-lightmap it, etc and so on? or do you just shift it in unity and hit bake? It is up to you, but at least we have options.
    JamesArndt likes this.
  23. lazygunn


    Jul 24, 2011
    I'd say for levels with a lot of dynamic light and with a lot of editing being made inside Unity, Beast is great, however if most of the grunt work is done in max etc. or you dont have a lot of dynamic or complex in-game lighting, the results of a vray bake can be beautiful, i also find placing and previewing light a hell of a lot easier in max than unity

    However, Beast comes with Unity and doesnt cost, although the lack of GI with Unity free is a complete bugger and dealbreaker for using Beast at all for me
  24. hippocoder


    Digital Ape Moderator

    Apr 11, 2010
    Well considering you can afford vray and 3dsmax it surely isn't hard to afford unity pro. But lets not go there :)
  25. lazygunn


    Jul 24, 2011
    I can't afford any of it, it was a struggle to get a normal android license, lets not go into circumstances
  26. E2R_Ben


    Oct 30, 2009
    Ive lightmapped my entire game using beast and its become a massive headache for me.
    The biggest problem is that when transferring the project from PC to mac unity decides to re generate the secondary set of UVs, meaning everything needs to be re lightmapped.
    This is a problem because im working remotely with my programming partner and he doesn't know his way round the lightmapper/have time to be messing about with it.

    That been said I think beast is faster than using Vray, most often my scenes just have on light, the sun, so beast is much better for this.
  27. Tysoe


    Jul 6, 2009
    I don't like Beast much either. I prefer to get as much done in max as possible where I have full control of the mapping. Beast doesn't seem to make very efficient UV's the few times I have used it so typically I would prefer to just do it all in max and lay out the UV's more intelligently and make better use of about 30 - 50% more space on my bitmaps.