Sunday, July 27, 2008

Surface quality and another beta-alpha release.

I have been spending some time on working out how to get a nice looking surface. As you can see from previous posts, the surface currently looks rather "blobby". So I have read papers and done some experiments. I think I am getting somewhere, but there is much more to be done yet.

First of all I now let the surface kernel be different from the SPH kernel. The SPH kernel has a lot of math that it must obey in order to work properly which a "viewing" kernel does not need. The result is a much nicer looking surface, but far from perfect. There is a catch, you need to set the isosurface threshold down to 1 rather than the default 500. Otherwise you won't see a thing. My current viewing kernel is (1-r^2)^2 and is often used with metaballs. The results is much better and just results in a small amount of roughness. With some adjustment even better results are possible.

Here is an example:
Threshold=1

With a larger threshold:
Threshold=3

Both in a composite:
Both together

Same but with polygons Ray traced:
Ray Traced Poly Surface

lower threshold and higher poly res. Note that rendering time is dominated by the mesh build. So this could be much faster for transparent fluids.
Ray traced with finer polys and larger threshold

And a composite:
The Above together in white this time

As you can see the threshold can make some difference. Generally there is no right value and it will need to be adjusted. It should be noted that other fluid packages has similar parameters that need to be adjusted. Surface tracking is not a exact problem and hence the different methods that are used to tackle the problem. Also this will make less difference with very small particle sizes. But it will be slower.

The final version will be almost be 100% based on a mesh. But a good mesh is very slow to build and hence may need to be backed in with the rest of the simulation. In real flow you can bake lots of mesh's to a single "particle" bake and you can then adjust the different parameters better for different views (aka close ups vers far shots...).
The trick with meshes is not that they are better, in fact they will be the same as the isosurface examples above. But note that these examples are only a little rough and some smoothing could make it almost perfect. And that what we do. We add post smoothing to the mesh, usually via a iterative scheme that can be tuned.

Unfortunately the mesh code has some issues. First is the fact that there are bugs. For some reason when the mesh preview is on the cpu goes to 100% and never stops. Has anyone else noticed this? The next is that there are some cases that i get null triangles. And the biggest is that is uses some code that nobody seems to have written. This creates clear issues with the GPL'ness of the code base and I may just have to rewrite it.

I will still keep the isosurface code and at this point it gives the best results. You get some performance issues however and the best way to deal with that is to turn on the useSampleGrid option. In my scene above they caused the render to be about 5-10 times faster, and the difference would be even greater with transparent fluids.

Other changes are there are now some options for fluid objects. The first is a dither and just randomizes the particle positions so as to loose perfect alignment effects. The other is x, y and z ratios. These are fill ratios in these respective directions. The default gravity is in the y direction so if we set y to 0.5 the object will be half full. Also the fluid objects and softbody objects no longer get "blobs" at the vertices's.

Add one more render:
Transparent

The updated plugin is at the same link as last time. The last post still makes up some of the release notes.

Do not forget to change the threshold to about 1 or a little more for this version.




Cheers

11 comments:

Anonymous said...

Bob - the surfaces in your videos look very good.
I try to redo a "splash" but it looks like a soapwater box with (metaball) bubbles.

Even with 10.000 particles and Rendergrid setting to 10 and Implicit Surface Threshold below 1 (!) (0.7 to be precise) I don´t get the same splash and I don´t get a good splash as with the old options.

Though it renders much faster.

Maybe it´s a good idea to have both options? For good surfaces the new mesh adoption and for splashes (or other more simulation related stuff) the "old fashioned" (isosurface) option?

I found the old option beside it´s backdraw in surface quality much easier to handle. But you explained already how much options tools like realflow show to the user...

Thanks for updating so fast again!

Harald

bob said...

I was starting to wonder if anyone noticed.

The lower the threshold, the more "ball" like it is.

The old fashion way is still there with a click on render isoSurface or whatever its called.

>I found the old option beside it´s backdraw in surface quality much easier to handle

Sorry I don't understand.

There is a few tricks to get a good splash. First of all remember scale. The defaults are for meters. That means if the "glass" is 1 unit wide think bath tub not glass.

The next thing is 2 options in the advanced options. This is tricky cus the advanced option bean editor is crap. YOU MUST hit enter in the field for the change to be accepted. I always close the advanced options and reopen then to check that the changes where really made.

The parameters to change are spacing and alpha. Alpha is a measure of viscosity and can even be set to zero. Spacing can be set to about 1 easily but this drives up the number of particles rapidly and slows down the simulation a lot. And I mean a lot. 1/2 the spacing means 8x the number of particles and about 8x times slower per particle (hence about 64x slower). Who said polynomial time is tractable!!!!

Spacing at about 1 is a good trade off.

Also if you are using a mesh then the rendergrid is not used only the mesh resolution.

cheers.

bob said...

by the way, we could use some fancy internet chat if we need to "discuss" things.... I heard they have this IRC? (thats a joke...the irc bit)

Anonymous said...

I tried another time with threshold a little higher (stupid as I am I used 50 and I see: Nothing).
:)

But else:
http://freenet-homepage.de/vidiot/AOI/Splash_1.avi
(xvid)

I´m trying again right now - with bodymass 50 instead of 5 to make the ball not swin again. Don´t know if I´m doing right?

Well done Bob - and regarding my statemant that the old version was easier to handle:
It´s just about to understand at least 5 of the 50 parameter to get it right. But I´ll work towards that goal.

Thanks
Harald

Anonymous said...

Regaring IRC:
I´ll learned a lot in IRC from FrancoisG and MarcC - but modeling is still faster than simulating.

While another simulation run take longer than an average IRC chat (on my machine at least).
But maybe you invite for a chat when you´ll get closer to a version 1?

There will surely be an audience - including me!

Harald

Anonymous said...

http://freenet-homepage.de/vidiot/AOI/Splash_2.avi

Now with the right settings - but rendering with raytracer still s*cks.
I have 22.ooo particle but the metaball size doesn´t seem to fit.

I go for another try...
:)
Harald

Anonymous said...

http://freenet-homepage.de/vidiot/AOI/Splash_2.avi

Now raytraced with 10 fps (only 1:30h on my single athlon)

It still looks blobby.
Do I need to change the metaball size somehow?

Harald

Anonymous said...

http://freenet-homepage.de/vidiot/AOI/Splash_3.avi

Should be No. 3 instead of 2 sorry
(I should not make to much use of c&p)

Anonymous said...

http://freenet-homepage.de/vidiot/AOI/Splash_1.avi
http://freenet-homepage.de/vidiot/Splash_2.avi
http://freenet-homepage.de/vidiot/Splash_3.avi

Stupid me - wrong paths

bob said...

none of the links after the first work for me

bob said...

Oh.... \looks sheepish