X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=extensions%2Fgdx-bullet%2Fjni%2Fsrc%2Fbullet%2FBulletMultiThreaded%2FGpuSoftBodySolvers%2FDX11%2FHLSL%2FUpdateNodes.hlsl;fp=extensions%2Fgdx-bullet%2Fjni%2Fsrc%2Fbullet%2FBulletMultiThreaded%2FGpuSoftBodySolvers%2FDX11%2FHLSL%2FUpdateNodes.hlsl;h=a16d89439a25dd25729e0d2cb7f7836552a886e6;hb=cbbe5aa80ad83d5e8a2ce3bbb9ea73c869758265;hp=0000000000000000000000000000000000000000;hpb=f06b93d715a12eac3c572f5d7aaa9f13c40ac058;p=mikumikustudio%2Flibgdx-mikumikustudio.git diff --git a/extensions/gdx-bullet/jni/src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/UpdateNodes.hlsl b/extensions/gdx-bullet/jni/src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/UpdateNodes.hlsl new file mode 100644 index 000000000..a16d89439 --- /dev/null +++ b/extensions/gdx-bullet/jni/src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/UpdateNodes.hlsl @@ -0,0 +1,49 @@ +MSTRINGIFY( + +cbuffer UpdateVelocitiesFromPositionsWithVelocitiesCB : register( b0 ) +{ + int numNodes; + float isolverdt; + int padding1; + int padding2; +}; + + +StructuredBuffer g_vertexPositions : register( t0 ); +StructuredBuffer g_vertexPreviousPositions : register( t1 ); +StructuredBuffer g_vertexClothIndices : register( t2 ); +StructuredBuffer g_clothVelocityCorrectionCoefficients : register( t3 ); +StructuredBuffer g_clothDampingFactor : register( t4 ); + +RWStructuredBuffer g_vertexVelocities : register( u0 ); +RWStructuredBuffer g_vertexForces : register( u1 ); + + +[numthreads(128, 1, 1)] +void +updateVelocitiesFromPositionsWithVelocitiesKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex ) +{ + int nodeID = DTid.x; + if( nodeID < numNodes ) + { + float3 position = g_vertexPositions[nodeID].xyz; + float3 previousPosition = g_vertexPreviousPositions[nodeID].xyz; + float3 velocity = g_vertexVelocities[nodeID].xyz; + int clothIndex = g_vertexClothIndices[nodeID]; + float velocityCorrectionCoefficient = g_clothVelocityCorrectionCoefficients[clothIndex]; + float dampingFactor = g_clothDampingFactor[clothIndex]; + float velocityCoefficient = (1.f - dampingFactor); + + float3 difference = position - previousPosition; + + velocity += difference*velocityCorrectionCoefficient*isolverdt; + + // Damp the velocity + velocity *= velocityCoefficient; + + g_vertexVelocities[nodeID] = float4(velocity, 0.f); + g_vertexForces[nodeID] = float4(0.f, 0.f, 0.f, 0.f); + } +} + +); \ No newline at end of file