StableFluid error on Unity2019.
For the StableFluid - Solver2D.cs, you didn't assign texture for the Project-Step2 kernel and it causes an error on Unity 2019 version. It is fine on Unity2017 but can be an issue on Unity2019.
I would suggest you add below code at line 93 and 117.
computeShader.SetTexture(kernelMap[ComputeKernels.ProjectStep2], velocityId, velocityTex);
And also on the Solver2D.compute, on 'AdvectVelocity' kernel function,
at line 234, you used GetDimensions(w,h) using density texturebuffer which requires SetTexture(density),
in this context, using velocity texturebuffer is better way to solve the error.
(x)
density.GetDimensions(w, h);
(o)
velocity.GetDimensions(w, h);
Thank you for the awesome code!
But after fixing those things, there is a weird horizontal artefact for the fluid simulation. I am having look at it and once I solve the problem, I will share it as well.
Not sure if you already fixed this, but adding *-0.5 ** before the sampling in ProjectStep2 seems to have fixed it (same as ProjectStep1):
`[numthreads(THREAD_X, THREAD_Y, THREAD_Z)] void ProjectStep2 (uint2 id : SV_DispatchThreadID) { uint w, h; velocity.GetDimensions(w, h);
if (id.x < w && id.y < h)
{
[unroll]
for (int k = 0; k < GS_ITERATE; k++)
{
prev[id] = float3(
-0.5 *
(prev[id].y + prev[uint2(id.x - 1, id.y)].x +
prev[uint2(id.x + 1, id.y)].x +
prev[uint2(id.x, id.y - 1)].x +
prev[uint2(id.x, id.y + 1)].x) / 4,
prev[id].yz);
SetBoundaryDivPositive(id, w, h);
}
}
}`