Torque Shader EngineTorque Shader Engine Documentation
CVS Revision Label 0.1.x

Chapter 7. Miscellaneous Features

Table of Contents

Planar Reflections

This chapter is reserved for miscellaneous features of TSE that don't fit in other sections.

Planar Reflections

Planar reflections are simply reflections on a large flat surface (a plane). They are typically used for reflective floors and mirrors mounted on walls. There are several limitations for using planar reflections:

  • Only work on interiors

  • Do not reflect terrain

  • Support 1.4 level pixel shaders at a minumum - will not work on Geforce 3 and 4.

Despite these limitations, they are relatively efficient (provided you do not use too many in the same scene). TSE will group surfaces that are co-planar (lie on the same plane) so that they can all use the same reflect buffer. This means it is possible to have many parts of the same floor be reflective while doing the reflection render once. Ie. you can efficiently render a scene with wet asphalt that has lots of puddles.

How to use

To use planar reflections, you must first map the surface(s) you want to be reflective to a CustomMaterial. The CustomMaterial can use the ReflectBump and Reflect shaders that have been included in the demo/server/scripts/shaders.cs. Specify planarReflection = true in the material, and every surface that uses that material will be reflective.

Example 7.1. Sample CustomMaterials for 2.0 and 1.4 pixel shaders respectively:

datablock CustomMaterial( ReflectBumpMat )
{
   texture[1] = "$backbuff";
   texture[0] = "~/data/interiors/junk/oak_floor";
   texture[2] = "~/data/interiors/junk/woodfloor2_b";
   shader = ReflectBump;
   version = 2.0;
   planarReflection = true;
};

datablock CustomMaterial( ReflectMat )
{
   texture[0] = "~/data/interiors/junk/oak_floor";
   texture[1] = "$backbuff";
   shader = Reflect;
   version = 1.4;
   planarReflection = true;
};
                    

Note the $backbuff keyword used in each material. This tells TSE to put the reflect texture into the specified texture unit.

The ReflectBump shader will perturb the reflection by the supplied bumpmap for a bumpy-reflective effect.