GAME PROGRAMMING RESOURCES

ALPHA TEXTURE MAPPING

Open, compile and test the AlphaTexture project by following the procedure described in the Quick Start Tutorial for the BallGame project.

The source code is fully commented and examining it is strongly recommended!

Don't forget to refer to Reference document for details on all functions called in the source code!

The example shows how to dynamically set render priority for two partially translucent balls so that they always render properly.

Press [Esc] to exit the demo.

REMARKS

  • By default, 3Impact will render a translucent surface where the alpha information for each pixel in the texture image is less than the maximum allowed (typically 255). The lower the alpha value, the more transparent the surface.


    The first image is the RGB texture image. The second image is the alpha map; where the pixel is darker, the alpha value is lower (more transparent). The third image is what the demo ball looks like with the resulting RGBA (alpha) texture applied to it.


  • In order to render transparent surfaces, you can make image files with embedded alpha information and use those images as textures for your meshes. Image formats supporting alpha are .dds, .tga and .png. Microsoft®'s DirectX® Texture Tool is an user-friendly and free utility to generate .dds image files from an RGB .bmp file and an alpha-map .bmp file.


  • Alternatively, you can apply non-alpha RGB images to your meshes in your modeler, and then apply to the mesh, as alpha map, any additional image file, by using the iMeshAlphaTextureChange() function.

    This technique is shown in the AlphaTexture demo source code (see above). Advantages are that you don't need any special tool to make image files that support alpha information, and you can dynamically change alpha maps.