Graphics Reference
In-Depth Information
projection space outputs that the rasterizer can work with. In particular, all geometry up
until this point has been in world space, but upon exit from the domain shader, it must be
in clip space the only exception to this is if a geometry shader is bound to the pipeline, in
which case you can defer this projection until then.
struct DS_OUTPUT
{
float4 position : SV_Position;
float3 colour : COLOUR;
};
float SampleHeightMap(float2 uv)
{
// - Must use SampleLevel() so we can specify the mip-map. The DS has no
// gradient information it can use to derive this detail...
// arbitrary bias to make the output more aesthetically pleasing...
const float SCALE = 3.0f;
return SCALE * texHeightMap.SampleLevel( smpHeightMap, uv, 0.0f ).r;
}
[domain("quad")]
DS_OUTPUT dsHain( HS_PER_PATCH_OUTPUT input,
float2 uv : SV_DomainLocation,
const OutputPatch<HS_OUTPUT, 4> patch )
{
DS_OUTPUT o = (DS_OUTPUT)0;
// We need to take the three world space
// coordinates in patch[] and the interpolation
// values in uvw (barycentric coords) and determine
// the appropriate interpolated position.
float3 finalVertexCoord = float3( 0.0f, 0.0f, 0.0f );
// u,v
// 0,0 is patch[0] .position
// 1,0 is patchfl] .position
// 0,1 is patch[2] .position
// 1,1 is patch[3] .position
/*
0--1
/
/
2--3
*/
finalVertexCoord.xz = patch[0] .position.xz * (1.0f-uv.x) * (1.0f-uv.y)
+ patchfl].position.xz * uv.x * (1.0f-uv.y)
+ patch[2] .position.xz * (1.0f-uv.x) * uv.y
+ patch[3] .position.xz * uv.x * uv.y
;
Search WWH ::




Custom Search