X-tree techniques for tracks
|Home||X-trees are simple shapes for tracks.|
When making tracks you often want to add trees. Sometimes lots of them. An often-used technique for this is to use so-called X-trees, which references to the fact that from the top they look like an 'X' symbol. An example from Carlswood is shown below:
3D geometry of each X tree
These trees may look as though they're built from 2 quads, but in fact it's really 4. Each quad is in fact 2 triangles, so this comes upto 8 triangles per X tree. Each side is modeled twice; one for the front side, and one for the backside. This is needed for the normal to point in the right direction; if you would just use 'cull=none' in the track's shader file (track.shd) the normal would point the wrong direction for one of the two sides. So create 2 polygons and just leave culling to its default (=back). This allows the Cg shaders for X trees to calculate appropriate normals for the tree pixels, based on its geometric normal and the flow along the tree texture.
Take care of the UV (texture) coordinates; the vertical coordinates should run from 0 (bottom) to 1 (top), and the horizontal coordinates from 0 (left) to 1 (right). This is needed to fake a normal across the polygon which simulates a cylinder-like tree shape.
Shading of X-trees
Regular shading of these X-trees would seriously expose the way they are built (2 simple polygons, or 4 visible triangles). See the example below for bad shading based on the regular triangle normals:
To rectify this, use the standard_xtree_v.cg and standard_xtree_f.cg shaders in your track.shd.
} ... shader_tree1~vf_xtree
alphafunc=gequal 128 depthwrite=1
This leads to the following image:
(last updated November 13, 2012 )