Graphics Reference
In-Depth Information
Figure 9.5. Input assembler layout for a single tile.
As shown in Figure 9.5, the first 4 control points
(I 0 -I 3 surrounding the red square) define the area that
will have geometry generated and rendered, while the
8 control points defining the neighboring cells (I 4 —I 11 )
are purely informational and allow the hull shader to
correctly assign the tessellation factors. Note that the
code makes use of the clamp() macro, which literally
does what it suggests—clamps the first parameter to
be in the range defined by the second and third param-
eters. The effects of this will be better demonstrated
later, but for patches around the edge of the terrain,
this sets the midpoint of the neighboring patch to be
Figure 9.6. Example heightmap.
the midpoint of the edge, instead. This gives good results, is significantly better than any
sort of modulus/wrapping/border operator, and is more analogous to texture gutters.
The final input required is the heightmap itself. The code in Listing 9.3 is a bit of an
anticlimax compared with the previous two—it simply loads Figure 9.6 into memory as a
texture resource.
// Load the texture
m_pHeightMapTexture = m_pRendererll->LoadTexture
( std::wstring( L ". ./Data/Textures/TerrainHeightMap.png" ) );
Search WWH ::




Custom Search