Turning normal maps off with LOD


Trp. Jed
03-09-2007, 09:41 AM
Thought some of you might find this trick useful if you have a model with normal maps.

Normal maps are great close up, but often when the model is far away, the normal map becomes ineffective if its only showing very small details. A good example would be trees where the bark normal can be quite intricate close up, but at 500 metres away, you'll never notice it.

So why would you want to turn normals off with LOD? Well apart from the fact their not doing much to the visual appearance of the tree, it can have a very *slight* effect on improving performance.

For a single model it's probably negligable but if theres a lot of normal mapped models in view it can help a bit.

So how do you do it?

First of all you need to make 2 versions of your material VMT, one with the normal map, one without. e.g.

bark01.vmt

"VertexlitGeneric"
{
"$basetexture" "models/props_trees/bark01"
"$bumpmap" "models/props_trees/bark01_normal"
"$model" 1
"$surfaceprop" "wood"
}


bark01_nonorm.vmt

"VertexlitGeneric"
{
"$basetexture" "models/props_trees/bark01"
"$model" 1
"$surfaceprop" "wood"
}


Next, in your QC where you define your LOD levels, add the replacematerial command as so:


$lod 125
{
replacemodel "tree_01_ref.smd" "tree_01_ref_LOD2.smd"
replacematerial "bark01" "bark01_nonorm"
}


What it will do is not only swap the model on the LOD change, but also swap the material VMT. As both VMTs use the same texture, no extra texture memory is being used.

As I said, the gains are probably negligable but every little helps!

Wile E Coyote
03-18-2007, 09:45 AM
Actually, I would think the gains would be incredible. I mean visually-wise. Take for instance those tree bark normal maps I made


Up close it makes the trees look absolutely stunning, but on many maps there are enough trees in view that it just DRAGS the FPS down. See that tree in the background? It doesn't NEED a normal map at that distance, unfortunately it's running one as well. With your above trick, only the highest LOD would be displaying them and only when they were really needed - when you were right on top of them. I hope more people read this.

FuzzDad
03-18-2007, 10:21 AM
The gains would be significant on bocage-type maps with lots of tree's. It's a good thing.

Trp. Jed
03-18-2007, 12:27 PM
I guess the biggest gain comes from the fact it bypasses the normal processing pipeline for the shader which I guess saves some cycles for your graphics card. Again, for one model its probably minimal but if theres a lot of them or even if you have a very large normal map (1024x1024) that would probably save quite a bit.

In theory this technique would even work with phong which has a much more complex pipeline. You could certainly turn it off with two VMTs after a set distance and probably gain some performance there too.

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.