Graphics Reference
In-Depth Information
// Local shape constraints
// One thread computes one strand
[ numthreads ( GROUP_SIZE ,1,1)]
void SimulateHair_B ( uint GIndex : SV_GroupIndex ,
uint3 GId : SV_GroupID ,
uint3 DTid : SV_DispatchThreadID )
{
uint globalStrandIndex = GROUP_SIZE ￿ GId . x ;
globalStrandIndex += GIndex ;
int offset =0;
int strandType =0;
if ( globalStrandIndex > 0)
{
offset =
g_GuideHairVerticesOffsetsSRV
. Load ( globalStrandIndex
1) ;
strandType = g_GuideHairStrandType
. Load ( globalStrandIndex
1) ;
}
uint numVerticesInTheStrand = g_GuideHairVerticesOffsetsSRV
. Load ( globalStrandIndex )
offset ;
// Local shape constraint for bending/twisting
{ float4 pos_minus_one = g_GuideHairVertexPositions
[ offset ];
float4 pos = g_GuideHairVertexPositions [ offset +1];
float4 pos_plus_one ;
uint globalVertexIndex =0;
float4 rotGlobal = g_GlobalRotations [ offset ];
for ( uint localVertexIndex =1; localVertexIndex <
numVerticesInTheStrand 1; localVertexIndex ++ )
{
globalVertexIndex = offset + localVertexIndex ;
pos_plus_one = g_GuideHairVertexPositions
[ globalVertexIndex +1];
// Update position i and i plus 1
// Update local/global frames
}
}
return ;
}
Listing 1.2. SimulateHair_B compute shader kernel.
1.9 Conclusion
The hair simulation of TressFX is optimized for real-time games in many as-
pects, such as using shape constraints and limits on the number of vertices per
strand. Therefore, it is required to understand its basic approaches to maximize
its performance and quality.
Search WWH ::




Custom Search