While Jacobi itself is quite simple it needs at least 10 iterations to produce acceptable results. However that results in a higher total time cost than the rest of the Navier Stokes Simulation together.

Are there any other ways to compute pressure with less steps? Since in my case it is purely visual I prefer performance over accuracy (as long as it looks acceptable)

example Jacobi Solver I am using:

float pN = tex2D(_Pressure, IN.uv + float2(0, _InverseSize.y)).x;
float pS = tex2D(_Pressure, IN.uv + float2(0, -_InverseSize.y)).x;
float pE = tex2D(_Pressure, IN.uv + float2(_InverseSize.x, 0)).x;
float pW = tex2D(_Pressure, IN.uv + float2(-_InverseSize.x, 0)).x;
float pC = tex2D(_Pressure, IN.uv).x;

float bN = tex2D(_Obstacles, IN.uv + float2(0, _InverseSize.y)).a;
float bS = tex2D(_Obstacles, IN.uv + float2(0, -_InverseSize.y)).a;
float bE = tex2D(_Obstacles, IN.uv + float2(_InverseSize.x, 0)).a;
float bW = tex2D(_Obstacles, IN.uv + float2(-_InverseSize.x, 0)).a;

if(bN > 0.5) pN = pC;
if(bS > 0.5) pS = pC;
if(bE > 0.5) pE = pC;
if(bW > 0.5) pW = pC;

float bC = tex2D(_Divergence, IN.uv).x;

float p = (pW + pE + pS + pN + _Alpha * bC) * _InverseBeta;

float2 uvmasks = min(IN.uv, 1.0 - IN.uv);
p = any(uvmasks <= _Border) ? 0.0 : p;

return p;

Update: I found this and it seems to exactly what I'm looking for.

They seem to extract the iterative constants that appear in the pressure solving jacobi formula with specific iterations into a kernel matrix. to future reduce cost they then reduce that matrix into a simple array by just picking the maximum value and use 2 passes to "spread" it back into a 2d matrix similar to 2 pass gaussian blur

as for converting or even understanding the formulas they used to compute the kernel as well as applying the kernel in each pass i simply can't make sense of it.

  • \$\begingroup\$ also as pdf shahinrabbani.ca/uploads/8/9/0/5/89055470/… \$\endgroup\$
    – HellGate
    Aug 25, 2021 at 14:38
  • 1
    \$\begingroup\$ It seems the video you've linked walks through the steps of their solution in some detail, even briefly showing the exact numbers they use for their separable convolution kernel. Can you clarify how you've tried implementing it so far, and what step you're stuck on or need help with? \$\endgroup\$
    – DMGregory
    Aug 25, 2021 at 16:25
  • \$\begingroup\$ @DMGregory i have not yet tried implementing it. sadly i am incredible bad at reading such mathematical formulas so i'm stuck trying to make sense of it. that is definitely something i need to work on a lot but right now i could use someone who either understands it or has already implemented it to convert it to readable (pseudo) code for me \$\endgroup\$
    – HellGate
    Aug 25, 2021 at 23:19
  • \$\begingroup\$ Try editing the question to explain the steps of the algorithm, as far as you understand them. Then we can help with the first step that's missing or incorrectly described. \$\endgroup\$
    – DMGregory
    Aug 25, 2021 at 23:21
  • \$\begingroup\$ i've tried but failed hard. while the basic idea behind it makes sense, when it comes to understanding the formulas i blank out. i at least added a basic summary of the idea behind it as how i understand it to the question but that's as far i can get. i would like to understand it some day and not just use magic numbers but staring some more hours at mathematical formulas that make no sense to me wont do it idk \$\endgroup\$
    – HellGate
    Aug 26, 2021 at 13:05


You must log in to answer this question.

Browse other questions tagged .