~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/UpdateNodes.hlsl

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
MSTRINGIFY(
 
2
 
 
3
cbuffer UpdateVelocitiesFromPositionsWithVelocitiesCB : register( b0 )
 
4
{
 
5
        int numNodes;
 
6
        float isolverdt;
 
7
        int padding1;
 
8
        int padding2;
 
9
};
 
10
 
 
11
 
 
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 );
 
17
 
 
18
RWStructuredBuffer<float4> g_vertexVelocities : register( u0 );
 
19
RWStructuredBuffer<float4> g_vertexForces : register( u1 );
 
20
 
 
21
 
 
22
[numthreads(128, 1, 1)]
 
23
void 
 
24
updateVelocitiesFromPositionsWithVelocitiesKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )
 
25
{
 
26
        int nodeID = DTid.x;
 
27
        if( nodeID < numNodes )
 
28
        {       
 
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);
 
36
                
 
37
                float3 difference = position - previousPosition;
 
38
                                
 
39
                velocity += difference*velocityCorrectionCoefficient*isolverdt;
 
40
                
 
41
                // Damp the velocity
 
42
                velocity *= velocityCoefficient;
 
43
                
 
44
                g_vertexVelocities[nodeID] = float4(velocity, 0.f);
 
45
                g_vertexForces[nodeID] = float4(0.f, 0.f, 0.f, 0.f);                                                            
 
46
        }
 
47
}
 
48
 
 
49
);
 
 
b'\\ No newline at end of file'