Detail Mapping for .dif interiors
by Nicolas Quijano · 04/08/2004 (8:59 pm) · 38 comments
Download Code File
Edit : removed obsolete URL, wording, typos
Works with HEAD as well as older versions, as the changes are very limited. If you haven't modified the material mapping system or the interiors, you can simply backup your copy of the affected files, and just install these in their place, rebuild TGE, and you'll be ready to add detail textures to your difs.
Detail texturing is done by adding a material mapping by binding a detail texture to a normal interior texture.
You can specify an alpha factor value between 0.0 and 1.0 for each mapping, as the last parameter.
A value of 1 will make the detail texture completely opage, meaning it will hide the base texture completely.
At this point, using a .png texture with an alpha channel leads to unpredictable results, so unless you like the results, don't use an alpha channel .png as your detail map.
I strongly recommend using a detail texture of the same size as your base texture, or even bigger. Beware of tiling patterns becoming more apparent in both textures : it drives the points even more that you should break big walls and surfaces into multiple pieces while modelling :)
It also darkens the surface a little, as you have to remember that .difs are also light by texturing with lightmaps, which are blended with the base texture. Then, the detail map is applied.
example :
Affected files are :
dgl/materialPropertyMap.h
dgl/materialPropertyMap.cc
interior/interior.h
interior/interior.cc
interior/interiorInstance.cc
interior/interiorRender.cc
Not sure about future plans for this resource, although there is a good chance I'll work on some improvements for it.
Big thanks to John Kabus, from synapsegaming for getting me on the right track :)
Hope it can help a few torquers out there,
Enjoy :)
Edit : removed obsolete URL, wording, typos
Works with HEAD as well as older versions, as the changes are very limited. If you haven't modified the material mapping system or the interiors, you can simply backup your copy of the affected files, and just install these in their place, rebuild TGE, and you'll be ready to add detail textures to your difs.
Detail texturing is done by adding a material mapping by binding a detail texture to a normal interior texture.
You can specify an alpha factor value between 0.0 and 1.0 for each mapping, as the last parameter.
A value of 1 will make the detail texture completely opage, meaning it will hide the base texture completely.
At this point, using a .png texture with an alpha channel leads to unpredictable results, so unless you like the results, don't use an alpha channel .png as your detail map.
I strongly recommend using a detail texture of the same size as your base texture, or even bigger. Beware of tiling patterns becoming more apparent in both textures : it drives the points even more that you should break big walls and surfaces into multiple pieces while modelling :)
It also darkens the surface a little, as you have to remember that .difs are also light by texturing with lightmaps, which are blended with the base texture. Then, the detail map is applied.
example :
addMaterialMapping("cement_wall", "detail: fps/data/interiors/scratches.png 0.5");Affected files are :
dgl/materialPropertyMap.h
dgl/materialPropertyMap.cc
interior/interior.h
interior/interior.cc
interior/interiorInstance.cc
interior/interiorRender.cc
Not sure about future plans for this resource, although there is a good chance I'll work on some improvements for it.
Big thanks to John Kabus, from synapsegaming for getting me on the right track :)
Hope it can help a few torquers out there,
Enjoy :)
About the author
Veteran and even a casualty of the mainstream game industry, as well as one of the early adopters of GG's tech : did the first builds of Orbz for MacOS X. A (great) Old One? And like one of 'em Cthonic thingies, from a great slumber or depths, I rise...
#2
04/08/2004 (11:14 pm)
Hey Nicolas - post a screenshot in the resource here as a comment, so that it comes out a lot larger. That way, people can get a really good idea how slick this is :-)
#3
Another thing I dont need to learn how to do.....
04/09/2004 (12:28 am)
I've been wanting this for a while now, THANKS!!!Another thing I dont need to learn how to do.....
#4
and "thats a cool looking bumpmap!".
So, Q, does this have bumpmapping in it? As far as I could tell, it dos'nt (and is on the todo).
Also, i get pretty black squares in a sort of grid, depending on what direction is faced when in an interior with detail maps.
04/09/2004 (2:06 am)
I keep getting the comment "is that bumpmapped?"and "thats a cool looking bumpmap!".
So, Q, does this have bumpmapping in it? As far as I could tell, it dos'nt (and is on the todo).
Also, i get pretty black squares in a sort of grid, depending on what direction is faced when in an interior with detail maps.
#5
If you haven't, I could test it out in our village, really cool addon.
04/09/2004 (2:08 am)
Great resource! Any change in framerate that you can document?If you haven't, I could test it out in our village, really cool addon.
#6
04/09/2004 (4:36 am)
Oooo sweet!
#7
04/09/2004 (12:28 pm)
Cheers, Nicholas. A much appreciated contribution.
#8
04/09/2004 (10:09 pm)
Heh, I have had code for this sitting in one of my torque work benches copies getting rusty, glad someone took the time to post it as a resource :)
#9
04/09/2004 (10:11 pm)
Hey, what else you got settin' over there, Xavier - anything else that should get released? :-)
#10
Previously I had tried to make multiple details for terrains, that corresponded with the texture that was bound to it, but I dont understand torque's rendering code, etc.
Maybe you could take a stab at this one?
BTW: Unreal's Engine uses detail mapping their interiors as well - which is why they look good up close still :P.
04/09/2004 (10:57 pm)
Beautiful! This is one of the things that torque lacks: detail mapping. And this definitelly takes the cake.Previously I had tried to make multiple details for terrains, that corresponded with the texture that was bound to it, but I dont understand torque's rendering code, etc.
Maybe you could take a stab at this one?
BTW: Unreal's Engine uses detail mapping their interiors as well - which is why they look good up close still :P.
#11
What this causes is for the alpha value to control how much the detail texture shows, rather then how much 'effect' it has... ok that makes little sense I know :) Put it this way, if I set an alpha of 1.0 for my detail texture I literally get the detail texture as if it were the base texture.
Is this how you intended for it to work? Or am I just being dumb... :/
04/10/2004 (1:36 pm)
I put this into my copy of torque yesterday with no hitches, however I appear to be having some weird visual glitches such as if the detail texture was literally on top of the base texture, rather then blended with it.What this causes is for the alpha value to control how much the detail texture shows, rather then how much 'effect' it has... ok that makes little sense I know :) Put it this way, if I set an alpha of 1.0 for my detail texture I literally get the detail texture as if it were the base texture.
Is this how you intended for it to work? Or am I just being dumb... :/
#13
If I set an alpha of 1 in init.cs any textures I have assigned that to simply become the detail1.png, whereas they should just just gain the highlights and lowlights (as the terrain does) from that texture.
Again, am I simply misunderstanding what should be happening?
04/11/2004 (4:11 am)
I'm using detail1.png (the detail tex thats used on the terrain from the sdk.)If I set an alpha of 1 in init.cs any textures I have assigned that to simply become the detail1.png, whereas they should just just gain the highlights and lowlights (as the terrain does) from that texture.
Again, am I simply misunderstanding what should be happening?
#14
Just try different textures, and use transparancy.. if that doesn't work either then I dunno - maybe it's not the right way.
04/11/2004 (4:25 am)
Strange. I'm not sure if Nicolas resource is working exactly the same way as the terrain details are. Just try different textures, and use transparancy.. if that doesn't work either then I dunno - maybe it's not the right way.
#15
edit: screenshot up... the numbers in the picture refer to the alpha value set in init.cs
04/11/2004 (4:27 am)
It seems to be less of a detail texture and merely a second texture on top that u can specify an alpha value to. Give me a few mins and i'll stick a screenshot up.edit: screenshot up... the numbers in the picture refer to the alpha value set in init.cs
#16
Nicolas has said himself he's thinking of making the code read .png transparancy rather than the value, which would make it more effective. But at the moment this does not work.
I'm going to try this myself in a couple of minutes. I'll keep you updated on my progress with some screenshots.
04/11/2004 (1:37 pm)
I think this is also what it is. But remember; the detail textures on the terrain are the same, I believe.Nicolas has said himself he's thinking of making the code read .png transparancy rather than the value, which would make it more effective. But at the moment this does not work.
I'm going to try this myself in a couple of minutes. I'll keep you updated on my progress with some screenshots.
#17
The detail textures on the terrain are like an overlay on the terrian textures, hence why the textures stay green (or whatever colours they are), not turn grey like the detail texture.
04/11/2004 (1:43 pm)
Its literally a drag and drop of files to include it unless you have changed stuff in those files, which is fairly unlikely probably.The detail textures on the terrain are like an overlay on the terrian textures, hence why the textures stay green (or whatever colours they are), not turn grey like the detail texture.
#18
It doesn't seem to relight correctly. In the screenshot below you can see how it looks like when I shot at the wall.
Also, notice the difference between the upper part of the house and the lower one that has recieved the detail map. It just made it brighter and blended 50 % or something (with 0.5 alpha).
That's not what I was expecting, rather than a detailmap.
Might be a bug with me running a non-HEAD build though.
www.innercircledev.net/strange.jpg
Edit: [img] didnt work :P putting it as a URL instead.
Second Edit: Took Craigs advice and now it's an image ;)
04/11/2004 (1:47 pm)
Erhm. Craig, I have encountered the same thing as you now - with one more thing to look out for if you decide to put this into your own project.It doesn't seem to relight correctly. In the screenshot below you can see how it looks like when I shot at the wall.
Also, notice the difference between the upper part of the house and the lower one that has recieved the detail map. It just made it brighter and blended 50 % or something (with 0.5 alpha).
That's not what I was expecting, rather than a detailmap.
Might be a bug with me running a non-HEAD build though.
www.innercircledev.net/strange.jpg
Edit: [img] didnt work :P putting it as a URL instead.
Second Edit: Took Craigs advice and now it's an image ;)
#19
I think we can safely say that this resource doesn't work as it should then :D
-Craig
04/11/2004 (1:52 pm)
or use [image] ;)I think we can safely say that this resource doesn't work as it should then :D
-Craig
#20
I'll wait for Nicolas to give a comment first.
04/11/2004 (1:55 pm)
Or at least how we thought it would work :PI'll wait for Nicolas to give a comment first.

Torque Owner Davis Ray Sickmon, Jr
Default Studio Name