Lightmapping before or after applying textures?

Im trying to get the hang of the concept lightmapping, but one thing I havent figured out is wether you apply the lightmap before or after youve applied the texture to the model? Ie. is it applied to the actual model as a sort of separate layer, or is it baked into the textures? (sorry if Im using totally incorrect terminology, but Im new to 3d)

Im really hoping that it is applied to the actual model, since I want to have the freedom to swap textures inside unity without having to do the lightmapping again.

If you bake out the lightmap separately you can combine it in one of the lightmap shaders, or if you want to bake it into the actual texture you can do that as well. If you’re targeting lower end hardware, the baking into the texture might be the best way to go.

Thanks :slight_smile: Yes, Im targeting the iPhone, so baking it into the texture would be the advisable thing to do?

As Ive understood from the tutorials, however, if youre working in maya/cinema 4d etc. you can edit the models inside the actual asset-folder, and the changes made in these programs (for instance baking a new lightmap) will automatically be updated in unity. Is this correct, or did I missunderstand how it fits together?

Baking light into the texture is not lightmapping. Lightmapping allows you to use the same texture for multiple objects, or have tiling textures, but have lighting be unique for each object. The highlights and shadows will not be at as high of a resolution as the diffuse color, but at least they’re there. Wherever you don’t need to reuse the texture, then yes, bake lighting into the texture - it will look better because the resolution of the light will match that of the diffuse texture. But again, that’s not lightmapping.

It’s correct. If you write over an asset in the Assets folder, with the same name, Unity will make appropriate updates automatically. Do keep in mind that you’ll need to have the preference set to automatically compress textures, though, if you want to see the effects of compression ASAP. But compressing textures takes time.

Thanks for your answer, Jesse :slight_smile:

But I must admit being a bit thick on the subject, because Im not completely getting what lightmapping is.

This is what I THINK it is:

A file containing the various intense shadows that has been calculated from the geometry in relation to the lightsource in the exporting editor (ie. maya, cinema 4d).

This file is then (to use a photoshop-analogy) opaqued, and placed on top of both the object and the texture.

If this is correct so far, does the calculation of the lightmap take into consideration the color of the texture (ie. if the background-object has a green texture, the lightmap becomes green-opaque and not black-opaque), or are the shadows generated in a gray-scale? If the latter is true, you could easily just replace the texture but not the lightmap directly inside unity. But if color related to the texture is involved in creating the lightmap, then you would have to re-export the whole thing from the 3d-editor.

That’s sort of accurate. The lightmap is a texture that represents how light or dark the geometry is, and it’s generally RGB, so you can have colored light and shadows. The main texture of the object is then multiplied with the lightmap. So if the lightmap is all white, the texture will not change color at all.

Like I said, there’s no point in using a lightmap if you’re not going to be reusing base textures on multiple objects, or tiling. The lightmap uses a second set of UVs, for as many objects as you like.

http://unity3d.com/support/resources/tutorials/lightmapping-in-maya
http://www.geartechgames.com/GearTech_Games/Beginning_a_Project/Beginning_a_Project.html

Great, that clears things up a bit. And special thanks for the second tutorial. What a great site with lots of tutorials on the subject :slight_smile: