11-08-2024, 10:39 AM
(This post was last modified: 11-08-2024, 09:47 PM by a172862967.)
Code:
void Start()
{
m_solver.OnSimulationEnd += ColorFromVelocity_OnInterpolate;
}
private void ColorFromVelocity_OnInterpolate(ObiSolver solver, float simulatedTime, float substepTime)
{
if (solver.backendType == ObiSolver.BackendType.Compute)
{
m_computeShader.SetFloat("DeltaTime", Time.deltaTime);
m_computeShader.SetBuffer(0, "ObiVelocityBuffer", solver.velocities.computeBuffer);
int threadGroups = ComputeMath.ThreadGroupCount(solver.allocParticleCount, 128);
m_computeShader.Dispatch(0, Mathf.CeilToInt(threadGroups), 1, 1);
}
}
Code:
RWStructuredBuffer<float4> ObiVelocityBuffer;
float DeltaTime;
[numthreads(128,1,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
ObiVelocityBuffer[id.x] = float4(0, DeltaTime*10, 0, 0);
}
I followed the instructions on this page and tried applying extra force, but nothing seems to have changed.
Did I do something wrong?