Texture Atlas and Lighting Map

nikki

16-02-2006 17:00:05

Hello everybody! :)

I am currently in the process of building a city for my game. I am using a texture atlas, and everything works perfectly (even real-time Ogre), but I come into a problem when trying to do lightmapping through render to texture. Because it's a texture atlas, there is only one texture. Setting the target map slot to self illumination doesn't work, because there is only one material for many objects. I am the programmer and artist for my game, and am not a max expert, so I wanted to post this question here since most of you must be more experienced than me. :)

Here's what my (unfinished) atlas looks like (it's actually 2048 * 2048, I have resized it):-
<Lioric has already seen it, so I've removed it to prevent copying>

Lioric

16-02-2006 21:24:39

There are several ways to do what you need

I would recommend you to attach all objects to a single object, then bake the lightmap, then detach the elements. In this way you do a single lightmap with correct texture uvs for all objects, the flattening uv modifier will work on all of the attached objects, creating a single texture space for all the objects, and the result is a single lightmapped material for all of the different objects

Other method is to create a material per object
Other method is bake the complete map, this is the texture will contain the color and the illumination information, for this you need to copy the uvs from the channel 3 to channel 1 after the process and replace the diffuse texture with the baked texture, but i recommend you to try the first option

nikki

16-02-2006 21:49:39

Thanks!

I'll try that tomorrow, I have to sleep now! :)
I have another thing to say. One part of the texture is used for many sides of a building. For example, the blue building texture is used on all four walls of a building, I am not using separate textures (within the atlas) for each side.

Lioric

17-02-2006 15:56:16

That is not a problem if you use the method recommended, as you will be using separate uv channels, the illumination channel (channel 3) will have flat, non-overlaping texture coords, evenly spaced, while the diffuse channel (channel 1) will continue to have the texture coords used by the texture

nikki

17-02-2006 18:05:44

I was thinking of using your last method because I think it would be better to have one huge texture rather than two huge textures. :)

But you know much better, so what do you think is better?

Lioric

18-02-2006 15:58:56

Creating a complete map will reduce the quality of the textures as images in the texture will be rescaled to fit all polygons without overlapping

You dont need two huge textures, you can use a smaller texture for the lightmap, the resolution will be compensated with the filtering and the color blending of the diffuse texture, a complete level can have 100 to 200 textures of different sizes (256, 512, 1024) for the diffuse and 1 or 2 small lightmaps textures (256 or 512) for all of the geometry

BergBoy

16-04-2006 07:52:04

I'm actually having the same problem. I have no idea how to solve it easily. If anyone has a quick way of fixing it (I am VERY much a coder and dont have any real idea of what I am doing...) then I will be most happy. Thanks :)

Lioric

16-04-2006 18:53:07

Do you need to create and use a complete baked map?

Try using a copy uv tool (there were some script on the net that provides that) and copy the uvs from the channel the baked texture was created to the channel 1 and put your baked image there

BergBoy

17-04-2006 05:52:52

Yeah, im a coder so I just cheaply built my world out of blocks in a BSP editor and imported the level into MAX. Then I applied a UVW map to the entire thing (Just a box map) and applied a brick material to walls and a concrete material to streets. Pretty simple and seemed fine until I needed to bake shadows. Im a little unsure how to put a baked lightmap onto an enviroment like that. Im assuming u bake a complete map and use a UVW unwrap for the entire world somehow... (I have no idea about max at all...) and apply that to an Ogre pass using the new UVWs with the prior pass being the base texture using the old UVWs... (hope that makes sense). Ive been at this for a few weeks now so ive kinda given up for now until a new method presents itself. If anyone has a step by step method (like "dummies guide to building a UVW unwrap for a 72 block based world so taht you can do a lighting map pass over the top of your old texture") then thanks in advance. Im sure im not the only one running into this kind of problem.

Evak

17-04-2006 06:39:52

for lightmapping if you have 3dsmax, I posted some useful things on the end of this thread:

http://www.ogre3d.org/phpBB2addons/view ... 94f354adec

BergBoy

17-04-2006 15:42:06

thanks champ, im checking it out now. i will let you know how things go. :D

BergBoy

18-04-2006 08:57:25

That "bakersville" script is awesome. I used Lioric's "Attach all like materials together" method and that script and BANG did the lightmaps in 10 minutes. Very awesome. Thanks guys!