Graphics Reference
In-Depth Information
14. And finally, we will add the quad domain shader. This time, we will perform a bilinear
interpolation using the Bilerp function from CommonTess.hlsl :
// Applies control point weighting with bilinear
// interpolation
[domain("quad")]
PixelShaderInput DS_Quads(
HS_QuadPatchConstant constantData,
const OutputPatch<DS_ControlPointInput, 4> patch,
float2 uv : SV_DomainLocation )
{
PixelShaderInput result = (PixelShaderInput)0;
// Interpolate using bilerp
float4 c[4];
float3 p[4];
[unroll]
for(uint i=0;i<4;i++) {
p[i] = patch[i].Position;
c[i] = patch[i].Diffuse;
}
float3 position = Bilerp(p, uv);
float2 UV = Bilerp(constantData.TextureUV, uv);
float4 diffuse = Bilerp(c, uv);
float3 normal = Bilerp(constantData.WorldNormal, uv);
// Prepare pixel shader input:
...SNIP as per the triangle tessellator domain shader
return result;
}
15. Within the D3DApp.CreateDeviceDependentResources method, compile the
TessellateTri.hlsl and TessellateQuad.hlsl shader functions, using the
hs_5_0 shader profile for each of the hull shader functions, and ds_5_0 for the
domain shader function.
16. We will also need to provide access to the PerObject and PerFrame constant
buffers within the hull and domain shaders. To do this, add the following code
to the D3DApp.CreateDeviceDependentResources method:
// Set our hull/domain shader constant buffers
context.HullShader.SetConstantBuffer(0, perObjectBuffer);
context.HullShader.SetConstantBuffer(1, perFrameBuffer);
context.DomainShader.SetConstantBuffer(0, perObjectBuffer);
context.DomainShader.SetConstantBuffer(1, perFrameBuffer);
Lastly, we need to update the renderers, so that they pass through the correct
input topology.
 
Search WWH ::




Custom Search