Lightspeed 3D: Surface Properties

The surface of a triangle is described by two functions:


There are several levels of shading, with different speeds. From fastest to slowest, these are:
  1. Flat, self-lit. Leave the fFlatShading flag set (the default), and after adding the triangle to the scene with myScene.AddTriangle(mytri), zero its normal with mytri.mNormal.Set(0,0,0). The engine will then draw the polygon in its color, with no regard to the lighting angle. (However, it will still appear dark if the light is on the far side of the triangle; i.e., it is still self-shadowing.)

  2. Flat, normal shading. This is the default. The triangle appears an even shade, but this shade depends on the angle it makes with the light.

  3. Flat, shading function. After creating your triangle, give it a shading function (e.g., mytry.mShadingFunc = new ShadingFunc). You may also need to set the vertex normals (mNormals[0] through mNormals[2]), if the standard triangle normal doesn't work for you. This option is used for Gouraud shading (done by the base class ShadingFunc), and can also be used for such things as bump maps or custom shaders.


There are two types of coloring, also with different speeds.
  1. Solid color. This is the default, and obviously faster than the alternative. The triangle appears as a solid color, defined by its mColors[0] property. This is a 3D vector with x,y,z mapped to red, green, and blue, each value in the range 0 to 1. For example, you'd set your triangle to bright yellow with myTriangle.mColors[0].Set(1,1,0).

  2. Color function. You can assign a color function, much like assigning a shading function. The base class (ColorFunc) simply interpolates between the color at each vertex (mColors[0] through mColors[2]). Derived classes could instead look up an appropriate color from a picture (i.e., a texture map), or compute a color based on some more complex function.
Last Updated: 6/13/98 . . . . . .