Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StableFluid error on Unity2019. #4

Open
wonkee-kim opened this issue Oct 16, 2019 · 2 comments
Open

StableFluid error on Unity2019. #4

wonkee-kim opened this issue Oct 16, 2019 · 2 comments

Comments

@wonkee-kim
Copy link

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!

@wonkee-kim
Copy link
Author

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.

@lkewis
Copy link

lkewis commented Oct 4, 2021

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);
    }
}

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants