Jump to content

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
Link to comment
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);    
    }

 

Link to comment
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
  • Like 2
  • Thanks 1
Link to comment
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 2
  • Thanks 1
Link to comment
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
Link to comment
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

 

Link to comment
Share on other sites

  • 2 years later...
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.

flip_splash.gif

Untitled-1.jpg

 

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

 http://fr.linkedin.com/in/vincentthomas

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...