3
cbuffer UpdateVelocitiesFromPositionsWithVelocitiesCB : register( b0 )
12
StructuredBuffer<float4> g_vertexPositions : register( t0 );
13
StructuredBuffer<float4> g_vertexPreviousPositions : register( t1 );
14
StructuredBuffer<int> g_vertexClothIndices : register( t2 );
15
StructuredBuffer<float> g_clothVelocityCorrectionCoefficients : register( t3 );
16
StructuredBuffer<float> g_clothDampingFactor : register( t4 );
18
RWStructuredBuffer<float4> g_vertexVelocities : register( u0 );
19
RWStructuredBuffer<float4> g_vertexForces : register( u1 );
22
[numthreads(128, 1, 1)]
24
updateVelocitiesFromPositionsWithVelocitiesKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )
27
if( nodeID < numNodes )
29
float3 position = g_vertexPositions[nodeID].xyz;
30
float3 previousPosition = g_vertexPreviousPositions[nodeID].xyz;
31
float3 velocity = g_vertexVelocities[nodeID].xyz;
32
int clothIndex = g_vertexClothIndices[nodeID];
33
float velocityCorrectionCoefficient = g_clothVelocityCorrectionCoefficients[clothIndex];
34
float dampingFactor = g_clothDampingFactor[clothIndex];
35
float velocityCoefficient = (1.f - dampingFactor);
37
float3 difference = position - previousPosition;
39
velocity += difference*velocityCorrectionCoefficient*isolverdt;
42
velocity *= velocityCoefficient;
44
g_vertexVelocities[nodeID] = float4(velocity, 0.f);
45
g_vertexForces[nodeID] = float4(0.f, 0.f, 0.f, 0.f);
b'\\ No newline at end of file'