# Implement Kernel (maths) in Vex

## Recommended Posts

Hello guys,

I try to implement the thin sheet feature (from this paper : http://www.cs.kent.edu/~zwang/schedule/zy11.pdf) but I'm stuck on this :

How can I implement this, or translate this into vex ?

I'm not sure if it's working with the grids and I should try to code it in a volume wrangle but I really don't know how I have to implement it.

I tried this in a point wrangle (in a sop solver) :

```int pts[];
float kernel_result[];

pts = pcfind(0, "P", @P, ch("search_radius"), chi("search_count"));

for(int i = 1; i < len(pts); i++){
vector pos1 = point(0, "P", pts[0]);
vector pos2 = point(0, "P", pts[i]);

float sum = (1 - pow(length(pos2 - pos1), 2) / pow(radius, 2));

float result = sum;
}
else{
float result = 0;
}
append(kernel_result, result);
}```

I'm sure it's not good and it's why I'm asking help !

If anyone here can help it would be much appreciated !!

Cheers,

Edited by DonRomano

##### Share on other sites

Just tried to edit the previous code for a better implementation, but I'm still sure I miss a lot of things....

```int pts[];
float kernel_result[];

pts = pcfind(0, "P", @P, ch("search_radius"), chi("search_count"));

float kernel(int a, int b, float c){
vector pos1 = point(0, "P", a);
vector pos2 = point(0, "P", b);
float sum = 1 - pow(length(pos2 - pos1), 2) / pow(c, 2);

if(0 <= length(sum) <= c){
float result = sum;
}
else{
float result = 0.0;
}

return result;
}

for(int i = 1; i < len(pts); i++){

float sum = kernel(pts[0], pts[1], radius);

float result = sum;
}
else{
float result = 0;
}
append(kernel_result, result);
}

```

##### Share on other sites

maybe gonna be some helpful stuff

• 1

##### Share on other sites

Thank you but I've already saw and dig those posts  except for the thesis, I didn't knew about this and it's awesome, thank's a lot !!

The big advantage of the method I try to implement is that it finds areas where the fluid is highly stretched and it adds particles there, so you don't loose the great amount of detail (with droplets etc..). I've already found a solution and I came up with this :

but the thing that bothers me is that I have a really tiny amount of droplets and some really long tendrils that are not that beautiful... and the fluid is expanding infinitely and I didn't found yet a solution to this.

Cheeeers,

Edited by DonRomano
• 1
• 1

##### Share on other sites

I love it.

Thank you for sharing with us

soon someone goona Help.

##### Share on other sites

great attitude, thanks for sharing rather than ask lots of questions then go into hiding...Grrrrrr!!!

• 2

##### Share on other sites

Thanks Noobini !!

So here's just a new test after some new vex trials :

I'm pretty happy with the result but it only works at the resolution 0.05, and with the minimum insertion threshold set at 0.25...

And I didn't manage to fix the infinite expansion of the fluid (as you can see below, he seems to be taking a shower with water coming from nowhere...)

Still have a lot of work...

Cheeeers,

• 2
• 1

##### Share on other sites

Thanks for the file. Do you have any Solver configuration tips, that will limit expansion? It seems to expand forever...

##### Share on other sites
12 minutes ago, Atom said:

Thanks for the file. Do you have any Solver configuration tips, that will limit expansion? It seems to expand forever...

Not yet.. I'm working on it !

##### Share on other sites

I guess basic velocity damping, in a GeometryWrangle can stop the expansion process, but it produces a strange dissolve effect, as an artifact.

I couldn't seem to get the GasDamp node to have any effect.

• 1

##### Share on other sites
2 hours ago, Atom said:

I guess basic velocity damping, in a GeometryWrangle can stop the expansion process, but it produces a strange dissolve effect, as an artifact.

I couldn't seem to get the GasDamp node to have any effect.

Interesting ! The expansion process is happening because the solver adds particles where there's a space (the min insert threshold) so wherever there's a space the solver fills it. Then, I managed to get droplets by adding a refining node that detects tendrils (using pc find and a threshold on neighbours count, as the tendrils points don't have much neighbours) and all the particles around there get snapped to form a droplet. But this technique works only with 0.05 res and it doesn't fix the infinite expansion issue.

For sure the dissolve artifact is coming from the surface tension. I'm still working hard on it to find a solution but for now I'm stuck and I don't really know where to go...

Cheers

##### Share on other sites
On 05/11/2019 at 5:58 PM, Atom said:

I guess basic velocity damping, in a GeometryWrangle can stop the expansion process, but it produces a strange dissolve effect, as an artifact.

I couldn't seem to get the GasDamp node to have any effect.

Never noticed this post, Im not a small fluid expert but i will have go for another take. Maybe your problem should not be from fluid infinitely expanding but you might create all the way too much particles where not needed. The overall volume should ideally stay constant (at least for perception), the overall water volume not be created from nowwhere. Can't you not check if the particles speed or surface tension of particles is not too high so the drop should detach or from tendrils  and no particles should be added?

________________________________________________________________

Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts

## Create an account

Register a new account