Graphics Reference
In-Depth Information
// n(011) - between vl and v2
case 11:
output.normal = ComputeEdgeNormal(ip, 1, 2);
break;
// n(101) - between v2 and v0
case 12:
output.normal = ComputeEdgeNormal(ip, 2, 0);
break;
}
return output;
}
Listing 9.19. Hull shader for curved point normal triangles.
Equations (9.61) and (9.70) allow for aspects of each evaluation to be broken out into
separate functions. Listing 9.20 covers these definitions.
float ComputeWeight(InputPatch<VS_OUTPUT, 3> inPatch, int i, int j)
{
return dot(inPatch[j] .position - inPatch[i].position, inPatch[i].normal);
}
float3 ComputeEdgePosition(InputPatch<VS_OUTPUT, 3> inPatch, int i, int j)
{
return (
(2.0f * inPatch[i].position) + inPatch[j].position
- (ComputeWeight(inPatch, i, j) * inPatch[i].normal)
) / 3.0f;
}
float3 ComputeEdgeNormal(InputPatch<VS_OUTPUT, 3> inPatch, int i, int j)
{
float t = dot
(
inPatch[j].position - inPatch[i].position
, inPatch[i].normal + inPatch[j].normal
);
float b = dot
(
inPatch[j].position - inPatch[i].position
, inPatch[j] .position - inPatch[i].position
);
float v = 2.0f * (t / b);
return normalize
(
inPatchfi].normal + inPatch[j].normal
- v * (inPatch[j].position - inPatch[i].position)
);
}
Listing 9.20. Hull shader utility functions.
Search WWH ::




Custom Search