Baking Lightmaps into Torque
by Tim Betts · in Artist Corner · 04/04/2005 (10:49 am) · 4 replies
I would like to bake my own lightmaps from Lightwave 3D 8.2 and use them within Torque. Has anyone does this from Lightwave or from another 3D application or otherwise generated a lightmap and integrated it with Torque? Assume no one has, here is the analysis I'm going to do, so perhaps someone can shoot holes in it for me.
How does map2dif store the lightmaps it generates? I assume within the DIF file. What format are they in? I'm thinking of changing map2dif to work in 2 phases. Phase 1, do all normal processing to generate lightmaps but instead of containing the actual light information, they would be 80% white and watermarked in black (or something obvious) to indicate the surface they belong to. I would also map a small white-only texture to all my surfaces that I wanted to bake, such as "emitter.jpg", then go into Torque and see how it looks.
Using this as a reference I would then modify map2dif again, so the lightmaps would additionally be written as BMP (or whatever DIF uses) to the output directory. Next, I would export the MAP of my interior to DXF, such that I could load it up in Lightwave. I would re-surface as needed to match the lightmaps (if possible) and bake the illumination using whatever lighting techniques I choose to generate a series of BMP (or whatever).
Finally, I would modify map2dif again to all me load up my lightmaps as the last minute and write those into the DIF file instead of it's own.
Does this sound like it would be possible? or am I missing the obvious?
Thanks -- Tim.
How does map2dif store the lightmaps it generates? I assume within the DIF file. What format are they in? I'm thinking of changing map2dif to work in 2 phases. Phase 1, do all normal processing to generate lightmaps but instead of containing the actual light information, they would be 80% white and watermarked in black (or something obvious) to indicate the surface they belong to. I would also map a small white-only texture to all my surfaces that I wanted to bake, such as "emitter.jpg", then go into Torque and see how it looks.
Using this as a reference I would then modify map2dif again, so the lightmaps would additionally be written as BMP (or whatever DIF uses) to the output directory. Next, I would export the MAP of my interior to DXF, such that I could load it up in Lightwave. I would re-surface as needed to match the lightmaps (if possible) and bake the illumination using whatever lighting techniques I choose to generate a series of BMP (or whatever).
Finally, I would modify map2dif again to all me load up my lightmaps as the last minute and write those into the DIF file instead of it's own.
Does this sound like it would be possible? or am I missing the obvious?
Thanks -- Tim.
#2
04/09/2005 (8:24 am)
Tim I don't think its possible to do lightmaps at the moment, as you will need 2 UV channels, and TGE and TSE only support 1. I hear that there may be better support for multitexturing support in the future. Like you I'm waiting for multiple UV's and more blend modes to play with. I will give torque another shot when these features arrive.
#3
I think the only issue is not one of mapping, since I assume following the execution of map2dif, the original surfaces/brushes have been split up into multiple surfaces. I assume this doesn't pose a problem for a tiling/repeating texture that is mapped to that material/surface/brush, but I assume a surface would already have to be split correctly to map my own multiple lightmaps to it. I think you know what I mean.
What I think would be instrumental in this, is if map2dif would also write out the model portion of the completed MAP in a format such as LWO (Lightwave) or 3DS. Anyone done this?
Once imported, you would know how the original MAP you wanted to light in a third-party application was going to be split. Knowing this, you could bake the illumination to the currect surfaces/brushes, map2dif based on the original MAP file, and then perhaps modify the code that generates the lightmaps to substitute my own or be utilized by a shader. Is there a way to see a wireframe view of the interior inside TSE's editor? Does map2dif convert the brushes to triangle or leave them as 4-point poly's? Anyway, I obviously have a lot to learn.
I'm likely way off base here in many points, but I like to have at least a working theory as to how this might be done and perhaps the best chance is by exploiting a shader to read the lightmap. I'm a rookie 3D guy, so I'm likely missing a lot technically, even an easier path.
Cheers -- Tim.
04/10/2005 (6:17 pm)
I'm geared towards TSE, so surely this be done with a shader. I admitedly don't really know how TSE handles its UV coordinates, but certainly it's easy to feed a shader with multiple textures (even including "$lightmap" for example), I assume I could also pass my own lightmap as simply another texture I have previously loaded. I think the only issue is not one of mapping, since I assume following the execution of map2dif, the original surfaces/brushes have been split up into multiple surfaces. I assume this doesn't pose a problem for a tiling/repeating texture that is mapped to that material/surface/brush, but I assume a surface would already have to be split correctly to map my own multiple lightmaps to it. I think you know what I mean.
What I think would be instrumental in this, is if map2dif would also write out the model portion of the completed MAP in a format such as LWO (Lightwave) or 3DS. Anyone done this?
Once imported, you would know how the original MAP you wanted to light in a third-party application was going to be split. Knowing this, you could bake the illumination to the currect surfaces/brushes, map2dif based on the original MAP file, and then perhaps modify the code that generates the lightmaps to substitute my own or be utilized by a shader. Is there a way to see a wireframe view of the interior inside TSE's editor? Does map2dif convert the brushes to triangle or leave them as 4-point poly's? Anyway, I obviously have a lot to learn.
I'm likely way off base here in many points, but I like to have at least a working theory as to how this might be done and perhaps the best chance is by exploiting a shader to read the lightmap. I'm a rookie 3D guy, so I'm likely missing a lot technically, even an easier path.
Cheers -- Tim.
#4
Take your .dxf that you exported from your CSG editor and load it in LW. (or .lwo if you are making a .dts) you'll have to reapply textures more than likely on a CSG model. Light it in layout and bake the new textures. It would be smart to make your UVs based on simple projections, ie all planar from X Y Z axis, so that you can reapply them in the CSG editor. After the baker has saved out all the files, you can use those to retexture your model in CSG editor. I have some cheesey but interesting examples here:
www.luminous-studios.com/flaktraks/d_bakedlight.jpg
www.luminous-studios.com/flaktraks/d_bakedlight2.jpg
04/10/2005 (7:09 pm)
TGE does split into triangles. There are debug render modes in the debug build... you can read about then in the docs. As for baking illumination it is possible to bake the lighting into the texture. I have done it with DTS but the idea is the same for DIF.Take your .dxf that you exported from your CSG editor and load it in LW. (or .lwo if you are making a .dts) you'll have to reapply textures more than likely on a CSG model. Light it in layout and bake the new textures. It would be smart to make your UVs based on simple projections, ie all planar from X Y Z axis, so that you can reapply them in the CSG editor. After the baker has saved out all the files, you can use those to retexture your model in CSG editor. I have some cheesey but interesting examples here:
www.luminous-studios.com/flaktraks/d_bakedlight.jpg
www.luminous-studios.com/flaktraks/d_bakedlight2.jpg
Torque Owner Tim Betts
Perhaps I posted in the wrong forum for this kind of question? Note, it's not specific to Lightwave, but more of theory or approach-validation before I start doing development. Please let me know if I should direct this question somewhere else.
Thanks -- Tim.