Jump to content
DonRomano

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 :

image.png.25bfae926a29bf8ca16aa258b6bc96eb.png

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 radius_mult = ch("radius_multiplier");
	float radius = @pscale * radius_mult;

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

	if(0 <= length(sum) <= radius){
		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 this post


Link to post
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 radius_mult = ch("radius_multiplier");
    float radius = @pscale * radius_mult;

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

    if(0 <= length(sum) <= radius){
        float result = sum;
        }
    else{
        float result = 0;
        }
    append(kernel_result, result);    
    }

 

Share this post


Link to post
Share on other sites

Thank you but I've already saw and dig those posts :D 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 :image.thumb.png.5e217b583cfab90e06cfc771bbda2524.png

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.

image.thumb.png.9aa9327ee560292158fa1c564ee46460.png

 

Cheeeers,

thin_sheet_test.hipnc

 

Edited by DonRomano
  • Thanks 1

Share this post


Link to post
Share on other sites

I love it.

Thank you for sharing with us :wub:

soon someone goona Help.

 

Share this post


Link to post
Share on other sites

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

  • Like 2

Share this post


Link to post
Share on other sites

Thanks Noobini !! 

 

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

 ezgif.com-video-to-gif.gif.e320730430e6bc38c0798830844eff2c.gif

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...)

5dc144ced3209_ezgif.com-video-to-gif(1).gif.8b0ba1df4d28192b1f7d347a409bf6dd.gif

Still have a lot of work...

 

Cheeeers,

thin_sheet_test.hipnc

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

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

flip_splash.gif

Share this post


Link to post
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...

flip_splash.gif

Not yet.. I'm working on it !

Share this post


Link to post
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.

flip_splash.gif

Untitled-1.jpg

  • Like 1

Share this post


Link to post
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.

flip_splash.gif

Untitled-1.jpg

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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×