Domain Shader (DS) stage
The Domain Shader (DS) stage calculates the vertex position of a subdivided point in the output patch; it calculates the vertex position that corresponds to each domain sample. A domain shader is run once per tessellator stage output point and has read-only access to the hull shader output patch and output patch constants, and the tessellator stage output UV coordinates.
Purpose and uses
The Domain Shader (DS) stage outputs the vertex position of a subdivided point in the output patch, based on input from the Hull Shader (HS) stage and the Tessellator (TS) stage.
Input
- A domain shader consumes output control points from the Hull Shader (HS) stage. The hull shader outputs include:
- Control points.
- Patch constant data.
- Tessellation factors. The tessellation factors can include the values used by the fixed-function tessellator as well as the raw values (before rounding by integer tessellation, for example), which facilitates geomorphing, for example.
- A domain shader is invoked once per output coordinate from the Tessellator (TS) stage.
Output
- The Domain Shader (DS) stage outputs the vertex position of a subdivided point in the output patch.
After the domain shader completes, tessellation is finished and pipeline data continues to the next pipeline stage, such as the Geometry Shader (GS) stage and the Pixel Shader (PS) stage. A geometry shader that expects primitives with adjacency (for example, 6 vertices per triangle) is not valid when tessellation is active (this results in undefined behavior, which the debug layer will complain about).
Example
void main( out MyDSOutput result,
float2 myInputUV : SV_DomainPoint,
MyDSInput DSInputs,
OutputPatch<MyOutPoint, 12> ControlPts,
MyTessFactors tessFactors)
{
...
result.Position = EvaluateSurfaceUV(ControlPoints, myInputUV);
}
Related topics
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om