Detail Textures
From Mod Wiki
Any texture can have a detail map added to it. This creates an extra layer of detail blended on top of the existing texture and normal map - a pass which is only drawn when the player is very close to the object. It can help to disguise lower-resolution textures (for example when picmips are enabled).
Contents
Adding Detail Textures to a Material
Detail textures are controlled on a per-material basis. Example below:
material test/detailmetal { surfaceType "metal" { diffusemap textures/metal_d.tga specularmap textures/metal_s.tga bumpmap textures/metal_local.tga diffuseDetailMap textures/detail/bump/metal_detail_d.tga specDetailMap textures/detail/bump/metal_detail_s.tga bumpDetailMap textures/detail/bump/metal_detail_local.tga detailMult 4,4,0,0 } }
- The bumpDetailMap section should point to a tiling normal map.
- The diffuseDetailMap section should point to a tiling diffuse map.
- The specDetailMap section should point to a tiling specular map.
- The first two numbers of the detailMult section are used to specify the X and Y tiling amount of the detail normals. Higher numbers make the detail normals tile more, resulting in finer details.
- Note: For non-square textures (such as texturesheets), the detailMult values should be the same aspect ratio as the texture. For example, for a 512x2048 texture sheet, use numbers like "2,8,0,0". If you use a different aspect ratio, the detail normals will appear stretched.
- The last two numbers denote the offset of the detail textures. Most of the time this probably won't have much visual impact, but can be used for tweaking the positioning of the details. A value of 1 offsets by a whole UV unit, so only decimal values between 0 and 1 are necessary.
Different Renderprograms
Sometimes you may have materials that need different render programs in order for detail textures to work properly. Here are some common special cases:
- If you want a material with the "alphatest" keyword to use detail textures, you must add program interaction/basic_detail_alphatest at the top of the stage.
- If you want a self-illuminated material with a glow map to use detail textures, you must add program interaction/selfillum_detail at the top of the stage.
- If you want a material with the Strogg "beetle-shell" effect to use detail textures, you must add program interaction/strogg_detail at the top of the stage.
- Note: The Strogg detail renderprogram looks for a self-illumination map by default, if you are not using a glow map then you must specify selfillummap _black after the regular diffuse, bump and specular texture declarations.
Tips
- Every material does not need to have diffuse, specular and bump detail maps - for example, in some cases just using a bump detail map alone can look better than using all three passes.
- To save texture memory, you could use a single texture for both the diffuse and specular detail textures, since in most cases they tend to match up anyway.
Masking Detail Textures with an Image
- In some cases, it can greatly improve visual quality if the detail maps are not applied evenly over a surface. For example, blending a detail normal into very dark shadows looks odd, since it flattens out the overall texture.
- If a texture would benefit from masking the detail textures out in certain areas, a good way of controlling this is by making a greyscale image, preferably as low-resolution as possible (for memory-saving reasons). 1/8 of the base texture size should be more than enough to make a decent mask.
- A quick method of making a mask to remove the detail textures from the shadows is just to open the texture's diffuse image, greyscale it, and tweak the levels (CTRL-L) in Photoshop to make most areas white, and the darkest areas black.
- In the mask texture, pure black will result in no detail textures being shown, pure white will apply the detail textures at full strength.
- Currently, in order to implement this, these lines (in bold) will need to be added to the material:
material test/detailmetal { surfaceType "metal" { program interaction/basic_detailwm diffusemap textures/metal_d.tga specularmap textures/metal_s.tga bumpmap textures/metal_local.tga bumpDetailMap textures/detail/bump/metal_detail_local.tga detailMult 4,4,0,0 detailWeightMap textures/metal_detailmask.tga } }
- For materials that use the Strogg renderprogram, use program interaction/strogg_detailwm.
- Note: The Strogg detail renderprogram looks for a self-illumination map by default, if you are not using a glow map then you must specify selfillummap _black after the regular diffuse, bump and specular texture declarations.
Toggling Detail Textures in the Game
- You can create a toggle bind to turn detail textures on and off by using bind <key> "toggle r_renderProgramLodDistance 1 250".
- If you want to set the range that the detail texture appears in the game, change the value of r_renderProgramLodDistance (defaults to 250). This is applied globally on the client side and cannot be controlled on a per-material basis - it is more of a graphics quality control setting.