Using separate UV coordinates for diffuse and bump map
by Thomas -elfprince13- Dickerson · in Torque 3D Professional · 04/14/2011 (9:30 am) · 6 replies
Hey everyone, I'm trying to figure out this whole Materials thing and I'm a little bit confused by my transition from fixed-function land to shader land.
I've been working on implementing rendering for the LDraw parts spec (a file format for Lego-like CAD software) which means implementing my own mesh classes. I'd like to extend the TSMesh system in the same way the Collada loader does, in order to use LDraw models in place of DTS models within my game.
It's my current understanding that bump maps and diffuse maps use the same set of UV coordinates within the model, but I'd like to be able to maintain a separate set of UV coordinates for my bump maps and my diffuse maps (or at least trick the bump maps into using the UV coordinates used by the lighting textures). I read the articles on extending the Material system over at Gameclay (http://gameclay.com/documentation/t3d-materials), but I'm still feeling a little lost as to where to begin with this task. Does anyone have any suggestions or pointers as to where I should begin?
I've been working on implementing rendering for the LDraw parts spec (a file format for Lego-like CAD software) which means implementing my own mesh classes. I'd like to extend the TSMesh system in the same way the Collada loader does, in order to use LDraw models in place of DTS models within my game.
It's my current understanding that bump maps and diffuse maps use the same set of UV coordinates within the model, but I'd like to be able to maintain a separate set of UV coordinates for my bump maps and my diffuse maps (or at least trick the bump maps into using the UV coordinates used by the lighting textures). I read the articles on extending the Material system over at Gameclay (http://gameclay.com/documentation/t3d-materials), but I'm still feeling a little lost as to where to begin with this task. Does anyone have any suggestions or pointers as to where I should begin?
About the author
C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.
#2
04/17/2011 (9:50 pm)
er i think one way of tricking it around is to not use a diffuse map, just set it as a flat colour, and apply the normal map, then use a detail map inplace of your diffuse, then look from there now their separated to see if you can do what you want with the detail layer while keeping the normal in place. Although im probably talking rubbish as its 5:30am lol
#3
Thoughts?
04/17/2011 (10:04 pm)
That's actually an interesting idea, and one I've considered, but it's my understanding that having a large number color changes would be a performance hit as it would require sending additional state for every model. Since I'll have a fixed dictionary of colors in use for every LDraw model in the scene, my plan was to have one texture atlas containing swatches of every color which has been declared within a file, and then a second set of texture atlases containing various maps to provide the fixed set of material finishes specified within the LDraw spec. This would essentially allow me to have a single material definition for EVERY model in the game (barring DTS/Collada/DIF/Terrain models placed in the level editor). The problem of course is that the size of the color swatches within the atlas would be to small to fit effective visually interesting maps for those finish-effects which share the same set of UV coordinates as the diffuse texture.Thoughts?
#4
04/18/2011 (2:18 am)
As an afterthought, doesn't Collada/DTS support a second UV channel ?
#5
04/18/2011 (5:55 am)
Quote:Yep. Although, for pure DTS workflow I don't think that there is an exporter that does so... yet. Which is one of the benefits of using Collada and the automagic conversion to the newer improved DTS format.
doesn't Collada/DTS support a second UV channel
#6
04/18/2011 (9:43 am)
Just to be clear - the problem isn't in having multiple UV channels, it's in specifying which UV channels are used for which purposes. Right now that's hard-coded into the shader generation for the default Material features.
Torque 3D Owner Thomas -elfprince13- Dickerson
Looks like these are hard-coded into the shader-generation code, though the access patterns for UV coordinates aren't consistent across different shader features.