This article's documentation is for the "GoldSrc" engine. Click here for more information.

User:SirYodaJedi/Creating detail textures from normal maps for GoldSrc

From Valve Developer Community
Jump to: navigation, search
Half-Life SDK/Textures
Icon-under construction-blue.png
This is a draft user page. It is a work in progress open to editing by anyone.
Remember to check for any notes left by the tagger at this article's talk page.

Template:Langbar

This page explains how to use existing normal maps to create detail textures that can be used to add more detail and simulate bumpmapping in GoldSrc GoldSrc's vanilla OpenGL renderer, without using up additional AllocBlock.

Icon-Important.pngImportant:This page assumes the existing textures are designed for traditional Source Source Engine-style rendering. If the textures are designed for PBR, they should be baked into traditional Blinn Phong textures first. Only a $basetexture (henceforth albedo) and $bumpmap (henceforth normal map) will be used.
Warning.pngWarning:Only normal maps (DirectX or OpenGL) work with this method; ssbumps cannot be used![confirm]
To convert ssbumps to regular normal maps, use a tool such as SsbumpToNormal.
Note.pngNote:
  • If the normal map is swizzled, it will be necessary to unswizzle. This usually means moving the alpha channel to the red channel. This tutorial explains how to do this in GIMP GIMP. (Source Source normal maps are not swizzled in vanilla shaders.)
  • If the normal map is a 2-channel normal map (blue channel is either not present or a single color), it is highly recommended to convert it to a 3-channel normal map. The Microsoft tool DirectXTex can do this, and vtex will do this automatically for textures with normal 1. (Source 2 Source 2 normal maps are usually 2-channel)

Creating the detail texture

Note.pngNote:This tutorial uses GIMP GIMP. This is possible to do in Photoshop, but the process may or may not be slightly different.
  1. Downscale the diffuse to a resolution where it will be roughly 1.0 scale (1 texel per unit), and add it to your WAD.
  2. Open the associated normal map texture in GIMP. Downscale it to 512x512 or lower if it isn't already (1024x1024 or lower in Sven Co-op).
    Tip.pngTip:For best results, the detail texture should be at least double the resolution of the WAD texture (ex: 64x64 detail for 32x32 WAD, 256x256 detail for 128x128 WAD).
    Icon-Bug.pngBug:The detail texture must be a power of two for mipmaps to be generated correctly, regardless of the WAD texture resolution (ex: 256x256 detail for 96x96 WAD).  [todo tested in?]
  3. In the Colors drop down menu, choose the Components submenu, and click Decompose.
  4. Set the color model to RGB, and make sure "Decompose to layers" is selected. Click OK.
  5. If you have an OpenGL normal map, skip to step 6.
  6. If you have a DirectX normal map, select the "Green" layer, then click "Invert" in the Colors drop down menu.
  7. Next, select the "Blue" layer, then click "Brightness and Contrast" in the Colors drop down menu. Set brightness to -127, then click OK.
    Skipping this step will result in an exaggerated brightness boost when the detail texture is applied.
  8. In the Colors drop down menu, choose the Components submenu, and click "Recompose".
  9. Switch back to the first image. In the Image drop-down menu, click "Flatten image".
    File:Norm2detail - flatten image.png
    This will ensure that the image doesn't have an (unnecessary) alpha channel, which would mess up the texture in-game if the TGA is compressed.
  10. Convert the image to greyscale, then convert it back to RGB.
  11. Export as TGA, using these settings:
    RLE compression can be disabled, but that will waste file size with no benefit. As long as no alpha channel is present (step 8), the compressed TGA will load properly in-game.
  12. Set the detail texture to 1.0 1.0 scale in the detail.txt file.

Adapting for Source

Todo: Freeing up $detail slot by baking into $basetexture