Detail Textures

From The DarkMod Wiki
Jump to navigationJump to search

I think I've come up with a good way of blending detail textures. This method is designed to simulate the "soft light" blending of photoshop/GIMP. (it pretty much just modulates then scales by 2) The advantage over regular modulation is that a correctly designed detail texture won't change the average color of the material, whereas modulation will always darken the material. This means that if a player is far from a surface with a detail texture, you can switch the detail pass on/off without the player noticing any changes in brightness.

--Gildoran 17:00, 27 August 2006 (CDT)

Making the Detail Texture:

You need to make a greyscale detail texture. (actually, colored textures work just fine too - they'll tint the material) Middle-grey will leave the material unchanged. Darker colors will darken the material and lighter colors will lighten it. The average color of the detail texture should be middle grey, so that on the lowest mipmap level the detail texture doesn't noticably modify the material.

Simple Fixed Blending:

To blend the detail texture, add the following render pass to your material:

    blend gl_dst_color, gl_src_color
    map yourDetailTexture

You'll probably want to scale down the detail pass and maybe even rotate it. You can also apply more than one detail pass.

For an example using this method, download a sample FM package by Mortem Desino.

Scaled Intensity Blending:

The previous method has the disadvantage that the only way to control the intensity of the detail texture is to adjust the contrast of the image; it can't be tweaked per-material.

This method allows you to adjust the intensity of the detail image, at the expense of requiring an extra render pass. Also, the detail texture needs to be inverted. (though most detail textures would probably look fine without being inverted)

The render passes are as follows:

    blend gl_zero, gl_one_minus_src_color
    map yourDetailTexture
    rgb detailAlpha
    scale 2, 2 // or whatever
    blend gl_dst_color, gl_one
    map _white
    rgb detailAlpha/(2-detailAlpha)

In the above code, detailAlpha would be the intensity of the detail texture, ranging from 0 to 1. You could use something like parm3 if you wanted to scale it on the fly. Again, it's possible to use more than one detail pass.