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