SSとりわすれたけどこの後USB3.2Gen2のボードを指したら1000MB/s出るようになった
NiagaraDebuggerちゃんと使えた。
NeighberGrid3Dの範囲外だと当たらない、というのにデバッガを見るまで気づかなかった。やはりこういうのあるとありがたい
(バウンディングとGrid3Dの範囲は別物だったけど、いいヒントにはなった)
GPU負荷計測もできる。TestSimulationが50ms近くかかってる、とか。
なし
0個で 14ms
10個でxxms 18ms
50個でxxms 18ms
100個でxxms 18ms
200個でxxms 18.5ms
300個でxxms 18.5ms
400個でxxms 18.5ms
500個でxxxms 18.7ms
1000個でxxxms 18.7ms
10000個で 26.5ms
Grid3D
0個で 14ms
10個でxxms 38ms
50個でxxms 35ms
100個でxxms 38ms
200個でxxms 18.5ms
300個でxxms 18.5ms
400個でxxms 42.5ms
500個でxxxms 43.7ms
1000個でxxxms 45ms
5000個でxxxms 56.7ms
10000個で 96ms
総当たり
0個で 14ms
10個でxxms 19ms
50個でxxms 22ms
100個でxxms 26ms
200個でxxms 35.5ms
300個でxxms 44.5ms
400個でxxms 53.5ms
500個でxxxms 61.7ms
1000個でxxxms 105ms
2000個でxxxms 200ms
3000個でxxxms 200ms
5000個でxxxms NAms
10000個で NAms
総当たり+Grid3D(いみなし)
0個で 15ms
10個で9ms 19ms
50個で15ms 22ms
100個で23ms 27ms
200個で60ms 35ms
300個で75ms 44ms
400個で96ms 54ms
500個で110ms 63ms
1000個で300ms 108ms
0.5ms超えるとタイムアウトするらしい
<div onclick="obj=document.getElementById('oritatami_part').style; obj.display=(obj.display=='none')?'block':'none';">
<a style="cursor:pointer;">▶クリックで展開</a>
</div>
<div id="oritatami_part" style="display:none;clear:both;">
const int3 IndexOffsets [ 27 ] =
{
int3(-1,-1,-1), int3(-1,-1, 0), int3(-1,-1, 1), int3(-1, 0,-1),
int3(-1, 0, 0), int3(-1, 0, 1), int3(-1, 1,-1), int3(-1, 1, 0), int3(-1, 1, 1),
int3(0,-1,-1), int3(0,-1, 0), int3(0,-1, 1), int3(0, 0,-1),
int3(0, 0, 0), int3(0, 0, 1), int3(0, 1,-1), int3(0, 1, 0), int3(0, 1, 1),
int3(1,-1,-1), int3(1,-1, 0), int3(1,-1, 1), int3(1, 0,-1),
int3(1, 0, 0), int3(1, 0, 1), int3(1, 1,-1), int3(1, 1, 0), int3(1, 1, 1),
};
OutPosition = Position;
OutVelocity = Velocity;
// 途中で使う変数を定義
float3 FinalOffsetVector = {0,0,0};
float ConstraintCount = 0;
float3 OtherPos;
bool myBool;
int CurrNeighborIdx = 0;
/*
for( int i=0; i<NumParticles; i++){
NiagaraDataInterfaceParticleRead.GetVectorByIndex<Attribute="Position">(i, myBool, OtherPos);
if( myBool == true && InstanceIdx != i){
// 対象Particleと自身との距離と方向を計算
const float3 vectorFromOtherToSelf = Position - OtherPos;
const float dist = length(vectorFromOtherToSelf);
const float3 CollisionNormal = vectorFromOtherToSelf / dist;
// 重なりがあるかを計算(Overlapが0以上なら重なっている)
float Overlap = Radius - dist;
if( Overlap > 0.01 && dist > 0.1){
FinalOffsetVector += CollisionNormal * Overlap * Power;
ConstraintCount += 1.0;
}
}
}
*/
if( Age < 5 ){
float3 target = float3(0,0,150) - Position;
//OutPosition += target * 0.00002;
}
OutPosition.z += -Gravity * 1.0/InvDt;
//
float3 UnitPos;
NeighborGrid.SimulationToUnit(Position, SimulationToUnit, UnitPos);
int3 Index;
NeighborGrid.UnitToIndex(UnitPos, Index.x,Index.y,Index.z);
//float3 FinalOffsetVector = {0,0,0};
//uint ConstraintCount = 0;
//float TotalMassPercentage = 1.0;
int3 NumCells;
NeighborGrid.GetNumCells(NumCells.x, NumCells.y, NumCells.z);
int MaxNeighborsPerCell;
NeighborGrid.MaxNeighborsPerCell(MaxNeighborsPerCell);
for (int xxx = 0; xxx < 27; ++xxx) {
// for (int i = 0; i < MaxNeighborsPerCell; ++i) {
for (int i = 0; i < 1; ++i) {
const int3 IndexToUse =Index + IndexOffsets[xxx];
int NeighborLinearIndex;
NeighborGrid.NeighborGridIndexToLinear(IndexToUse.x, IndexToUse.y, IndexToUse.z, i, NeighborLinearIndex);
int CurrNeighborIdx;
NeighborGrid.GetParticleNeighbor(NeighborLinearIndex, CurrNeighborIdx);
// temp bool used to catch valid/invalid results for direct reads
bool myBool;
float3 OtherPos;
NiagaraDataInterfaceParticleRead.GetVectorByIndex<Attribute="Position">(CurrNeighborIdx, myBool, OtherPos);
const float3 vectorFromOtherToSelf = Position - OtherPos;
const float dist = length(vectorFromOtherToSelf);
const float3 CollisionNormal = vectorFromOtherToSelf / dist;
// 重なりがあるかを計算(Overlapが0以上なら重なっている)
float Overlap = Radius - dist;
if (IndexToUse.x >= 0 && IndexToUse.x < NumCells.x &&
IndexToUse.y >= 0 && IndexToUse.y < NumCells.y &&
IndexToUse.z >= 0 && IndexToUse.z < NumCells.z &&
CurrNeighborIdx != InstanceIdx && CurrNeighborIdx != -1 && dist > 1e-5)
{
//bool otherUnyeilding = false;
//TotalMassPercentage = 1.0;
if( Overlap > 0.01 && dist > 0.1){
FinalOffsetVector += CollisionNormal * Overlap * Power;
ConstraintCount += 1.0;
}
}
//float OtherRadius;
//DirectReads.GetFloatByIndex<Attribute="CollisionRadius">(CurrNeighborIdx, myBool, OtherRadius);
}
}
if( ConstraintCount > 0){
//OutVelocity += FinalOffsetVector;// / (ConstraintCount+1);
// 調整後のポジションと前フレームのポジションをもとに速度を更新
OutPosition += FinalOffsetVector/ (ConstraintCount);
}
if( OutPosition.z < 0 ){
OutPosition.z = 0;
// PrevPosition.z = OutPosition.z - OutVelocity.z *100;// (1.0/InvDt);
}
OutVelocity = (OutPosition - PrevPosition) * InvDt;
//OutVelocity += -OutPosition*0.0001;
折りたたみたい内容
</div>
パーティクルベースの水面レンダリング
https://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf