EnhancedMesh Direct3D Sample


This sample demonstrates mesh tessellation in Microsoft Direct3D. Mesh tessellation subdivides mesh triangles. This produces a mesh with finer geometry details which can produce better lighting results even with per-vertex lighting. Mesh tessellation is often used to implement a level of detail (LOD) technique where meshes closer to the viewer are rendered with more details, and meshes further away are rendered with less detail.

EnhancedMesh sample

Supported Languages

Path

Source: (SDK root)\Samples\Managed\Direct3D\EnhancedMesh
Executable: (SDK root)\Samples\Managed\Direct3D\Bin\x86\csEnhancedMesh.exe

How the Sample Works

The sample can run in one of two modes: hardware tessellation or software tessellation. The user can set the tessellation level to different values and see how the mesh changes in reaction to the level adjustment.

When running in hardware tessellation mode, the sample tessellates the mesh by setting the Device.NPatchMode property which sets the number of tessellation segments into which the device will tessellate each mesh segment. For instance, specifying 3.0 will cause each original segment in the input mesh to be tessellated into three segments. This tessellation happens in real-time, after the mesh draw calls in the render loop.

When running in software tessellation mode, the sample does not rely on the hardware to do on-the-fly tessellation. Therefore, the sample must process the mesh and obtain the desired detail level before rendering it. The code achieves this by calling Mesh.TessellateNPatches which takes an input mesh and a segment count, and then outputs another mesh that represents the tessellated version of the input mesh. The sample can then render this tessellated mesh using any standard mechanism.


Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center