Uniform Terrain Decalcomania
As part of our first year group project at the Academy of Interactive Entertainment we needed to create a terrain class. One thing that we wanted for our terrain was the ability to place scorch marks onto its surface. I searched the Internet for tutorials and examples but failed to find anything of substance; perhaps the topic was too simple or I needed to find a new search engine. Eventually, I established that decals were going to be the solution to my problem. Introduction: What Is A Decal?So what exactly is a decal, you may ask? Well, the American Heritage Dictionary of the English Language describes a decal as:
And the same dictionary describes decalcomania as:
From this we can gather that decal is short for decalcomania, which is all about transferring graphic overlays onto surfaces. That's exactly what we want to do - transfer our graphic overlay, or decal, onto our terrain surface. In terms of computer graphics, a decal is essentially a geometry mesh that replicates a portion of an existing mesh. This replicated geometry is then raised slightly above the original mesh and given the appropriate decal texture. The effect is like placing stickers onto the original geometry. In this article we will use the coordinate system found in 3D Studio Max, where, with respect to your computer monitor, +X is right, +Y is into the screen and +Z is up. So if you're looking down on the terrain (your line of sight is parallel with the Z-axis), the Y & X axis appear as they would in the Cartesian coordinate system. You can now forget about the Z-axis, as a terrain's Z-axis displacement, i.e. it's height, has no effect on our decals and is thus of no consequence. To make proceedings even simpler, we're going to place our terrain entirely in the first Cartesian quadrant, that is, the quadrant that is positive in both the x and y directions. Cell Alignment and Texture ClampingA cell is a square segment consisting of two triangle primitives belonging to a uniform terrain grid. As you would expect, decals do not always cover a complete cell or cells of a terrain, in fact, they are almost always found upon a fraction of a cell. To display a decal over a fraction of a cell we need to set the decal's texture to ‘clamp to the edge', this tells the graphics card to map edge texels to adjacent polygon regions that have texture UVs below zero or above one. A problem may occur when a decal texture is resized to a smaller resolution. Transparent edge texels becoming compromised from blending with adjacent, non-transparent texels. The fix this problem the transparent border of the decal texture is widened, so that when resizing occurs, there will still be fully transparent texels at the edge of the texture. |
|