3 cbuffer PrepareLinksCB : register( b0 )
\r
11 // Node indices for each link
\r
12 StructuredBuffer<int2> g_linksVertexIndices : register( t0 );
\r
13 StructuredBuffer<float> g_linksMassLSC : register( t1 );
\r
14 StructuredBuffer<float4> g_nodesPreviousPosition : register( t2 );
\r
16 RWStructuredBuffer<float> g_linksLengthRatio : register( u0 );
\r
17 RWStructuredBuffer<float4> g_linksCurrentLength : register( u1 );
\r
19 [numthreads(128, 1, 1)]
\r
21 PrepareLinksKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )
\r
23 int linkID = DTid.x;
\r
24 if( linkID < numLinks )
\r
26 int2 nodeIndices = g_linksVertexIndices[linkID];
\r
27 int node0 = nodeIndices.x;
\r
28 int node1 = nodeIndices.y;
\r
30 float4 nodePreviousPosition0 = g_nodesPreviousPosition[node0];
\r
31 float4 nodePreviousPosition1 = g_nodesPreviousPosition[node1];
\r
33 float massLSC = g_linksMassLSC[linkID];
\r
35 float4 linkCurrentLength = nodePreviousPosition1 - nodePreviousPosition0;
\r
37 float linkLengthRatio = dot(linkCurrentLength, linkCurrentLength)*massLSC;
\r
38 linkLengthRatio = 1./linkLengthRatio;
\r
40 g_linksCurrentLength[linkID] = linkCurrentLength;
\r
41 g_linksLengthRatio[linkID] = linkLengthRatio;
\r