Game Development Community

Add Custom Lightmaps to Interiors

by Ryan Mounts · 04/03/2008 (11:35 am) · 14 comments

Here's a new resource for adding your own lightmaps to your interiors in TGE. This is useful for getting advanced lighting from a 3D modeling package like 3dsmax into your lightmap, painting your lightmap by hand, or a combination of both.

Add Custom Lightmaps to Interiors

This is a modified version of map2dif_plus (v1.1). All original functionality remains, so you can replace your old map2dif_plus with no problem. There's a tutorial included to help get you started.

Here's a few pics showing off what you can do with it:

No Lightmap

i291.photobucket.com/albums/ll284/rmounts/Cornell4.jpg
Custom Lightmaps

i291.photobucket.com/albums/ll284/rmounts/Cornell1.jpg
i291.photobucket.com/albums/ll284/rmounts/Cornell2.jpg
i291.photobucket.com/albums/ll284/rmounts/Cornell3.jpg
NOTE: I did not change the map2dif_plus base code, so if you experience problems converting from a map to a dif, either your map is incorrectly modeled or you've encountered an existing map2dif_plus bug. I have no intention of tracking down and fixing all map2dif_plus bugs, so please do not contact me with problems like missing faces, malformed brushes, nonfunctional portals, etc. If you feel like you've encountered a problem due to the new lightmap functionality, then I'll definitely take a look at it.

#1
04/03/2008 (12:57 pm)
no images
#2
04/03/2008 (5:54 pm)
Great work. Do you have a TGEA version?
#3
04/03/2008 (7:14 pm)
I think a TGEA version may be my next project.
#4
04/03/2008 (7:30 pm)
OMG I must have this for TGEA.. Actually is there any reason that this wouldn't work under TGEA?

Interesting how the one with no torque lights looks way better than the one with them.

Do the colors affect things such as player models? For instance if he were to walk up into the box near the red wall would he look like he had red light on him?
#5
04/03/2008 (8:27 pm)
Well, this one won't work for TGEA because TGEA has it's own map2dif_plus. I'll have to modify that one to make it work. I haven't looked at any of the TGEA map2dif_plus code yet, but I assume it is very similar, so I'm hoping it won't be that difficult to port it over.

The one with no Torque lights looks better because it was created with a physically correct area light, so you get accurate intensity falloff and soft shadows. The drawback is that the player is not dynamically lit and no shadow is cast. So the next image is a compromise showing how you can use a Torque light to cast direct light on the player and shadows while still getting a decent global illumination feel.

The way lightmaps work has not changed, so the colors beneath the player still affect him. So you can walk up into the interior that has no lights and he will change colors depending on the lightmap color.
#6
04/04/2008 (3:31 am)
We don't use TGE so a TGEA version would be great indeed :)
#7
04/04/2008 (1:25 pm)
Do how does TGEA 1.7 handle lightmaps for polysoup objects? or are there still lightmaps?
#8
04/05/2008 (9:57 pm)
What a great tool! TGEA would be a great next project :D

Actually, if you want to share the source code, I'll take a crack at a TGEA version.
#9
04/13/2008 (6:54 am)
A version for TGEA would be great :)
#10
12/15/2008 (12:23 pm)
Any chance of releasing the code changes you did for map2dif_plus?
#11
12/15/2008 (1:35 pm)
Sure. I'm a little busy at the moment, but I'll try to package something up soon and post a link here.
#12
12/18/2008 (8:53 am)
Here is a link to the modified code. I pretty much just hacked through this, so there are hardly any comments. I did include a "Changes.txt" file that lists everything that was added to the map2dif_plus code, so you should be able to track down the changes and see how things work. You may not be able to compile this map2dif_plus code, because I seem to remember having altered some of the core TGE code on which map2dif depends. So if you get compile errors saying that a function's use doesn't match its definition, then that's the problem. If you run into that, let me know and I can get those changes for you too. I just don't have time to do that myself at the moment.
#13
12/18/2008 (1:58 pm)
Thanks a lot for the code and good work improving Torque's lighting with this and the AO addition.

The missing functions so far are all from the Interior class. If these changes don't depend on changes elsewhere then your Interior.h and Interior.cc would finish it off.
getMaterialList
getNumLightmaps
addLightmap
addLightmapKeep
removeLightmap
removeLightmapKeep
getNumLightmaps
getLightmap
setLightmap
setLMTexGenEQ
setNormalMapIndex
setMapOffsetX
setMapOffsetY
setMapSizeX
setMapSizeY
#14
12/19/2008 (7:21 am)
I updated the link above so that it now has the interior files. Just let me know if we're still missing anything!