Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: Optimus on February 26, 2010

Title: [LIQUID] Water3D
Post by: Optimus on February 26, 2010
Hello!

This is my attempt to do the classic 2D water ripples effect but in a 3D grid this time. I had to take the old algorithm that uses a filter and make a 3d version of it and try taking more neighbors in 3d space and different combinations till I get something that looks ok and doesn't flood. Normally I could research more on it to see the maths behind the balance for 3D but I don't have much time. I am still very happy with how the effect looks. It's 112*112*112 voxels (well, dots) and around 22-25fps here (I also stall it to 25 because if it goes too fast it doesn't look good).
Title: Re: [LIQUID] Water3D
Post by: Voltage on February 26, 2010
Ha!  Cool idea Optimus.

Looks really good.  :clap:
Title: Re: [LIQUID] Water3D
Post by: Positron on February 26, 2010
Interesting idea. Looks good Optimus.
Title: Re: [LIQUID] Water3D
Post by: benny! on February 26, 2010
Looking very good, buddy! Well done and thanks for the entry!
Title: Re: [LIQUID] Water3D
Post by: padman on February 26, 2010
Nice effect!  :)
Title: Re: [LIQUID] Water3D
Post by: rdc on February 26, 2010
That is a very interesting idea. I never would have thought of it. The execution is very good. Nice entry.
Title: Re: [LIQUID] Water3D
Post by: Hotshot on February 26, 2010
very good :)
Title: Re: [LIQUID] Water3D
Post by: combatking0 on February 26, 2010
Very nice - certainly a contender.
Title: Re: [LIQUID] Water3D
Post by: janer on February 27, 2010
 :clap:
cool one!! this is just perfect for a background of a cracktro/intro!
Title: Re: [LIQUID] Water3D
Post by: Shockwave on February 28, 2010
Very interesting looking effect Optimus :)

Thanks for posting it!
Title: Re: [LIQUID] Water3D
Post by: hellfire on February 28, 2010
It's 112*112*112 voxels
It's a pretty cool idea but if you're filtering a 3d-grid I expected the circles (which are typical for this kind of effect) to become spheres.
At the moment it looks more like applying a 2d-water-effect to 3d-rendered particles.
Title: Re: [LIQUID] Water3D
Post by: pixotica on March 01, 2010
That is awesome, You could do so many things with this , cycle the colors and so on. I can see if I keep hanging around here I will be learing some free basic. It's amazing what can be done with numbers.
Title: Re: [LIQUID] Water3D
Post by: combatking0 on March 01, 2010
I can see if I keep hanging around here I will be learing some free basic.

We've been rumbled! ;D
Title: Re: [LIQUID] Water3D
Post by: Optimus on March 02, 2010
Quote
It's a pretty cool idea but if you're filtering a 3d-grid I expected the circles (which are typical for this kind of effect) to become spheres.
At the moment it looks more like applying a 2d-water-effect to 3d-rendered particles.

In fact I am not sure at the moment if they are spheres or circles. I thought too they would be spheres. I am applying a 3d version, going through each dots and instead of taking 4 neightbors I am taking 6 neighbors in all three dimensions. But the simulation was wrong, it was either fading away or overflooding when I changed something, and I found something in balance that I am not sure it's right.

I am actually using this now:

wbuffer2 = ((wbuffer1[i-1] + wbuffer1[i+1] + wbuffer1[i-vsize] + wbuffer1[i+vsize] + 2*wbuffer1[i-vvsize] + 2*wbuffer1[i+vvsize]) >> 2)  - wbuffer2;
      wbuffer2 -= (wbuffer2 >> 8);

// vsize is voxel width. If the voxel is n*n*n then vsize = n and vvsize = n * n

The think is, the original inventor of the 2d effect didn't just thought of filtering and subtracting and damping accidentally. There was a tutorial where he solved some differential equations to reach that point. I would read and try to understand it. The 3d version shouldn't be to just to do equivalent stuff in 3d as in 2d but I should try to understand the original proof of the 2d water effect and apply the same proof in 3d and see what results. Now I just found the above to have some kind of balance, but I am not sure if the circles are spheres or not (maybe the projection doesn't let it show).
Title: Re: [LIQUID] Water3D
Post by: hellfire on March 04, 2010
Quote
Code: [Select]
wbuffer2 = (
  wbuffer1[i-1] +      // left
  wbuffer1[i+1] +      // right
  wbuffer1[i-vsize] +  // top
  wbuffer1[i+vsize] +  // bottom
2*wbuffer1[i-vvsize] + // front
2*wbuffer1[i+vvsize]   // back
) >> 2
...
You probably scaled only "front" and "back" to get the damping factor right without using too many operations and keeping it power-of-2.
But your filter now emphasises the other directions.
Title: Re: [LIQUID] Water3D
Post by: Optimus on March 05, 2010
Initially I wanted to do it in a more right way, without caring about optimization.
I just did the same logic of 2d in 3d at first. The thing is it didn't work.

First try: left, right, top, bottom, front, back, dividing by 3. Also tried not to divide by 3 but by more or less.
Another try: I was taking all 27 voxels around the voxel, or 27-8 (all except those 8 at the far corners).

In all these cases I either have to divide by something that dampens it very very fast done and you don't see nothing (flashing points only) or the colours are bleeding and there is overflow. Simply, I couldn't find the balance. The one I wrote wasn't for optimization purposes but because it seemed to somehow work.
Title: Re: [LIQUID] Water3D
Post by: Jim on March 05, 2010
One thing to remember is that the diagonal corners are further away than the orthogonal neighbours, they are sqrt(3), about 1.75 scale factor would be needed.
If you want to use whole numbers or powers of 2 for division, then multiply some of the numbers up before the division.

Jim
Title: Re: [LIQUID] Water3D
Post by: Kirl on March 05, 2010
Wow, that's beautifull!

A bit of Interactivety would be even cooler though, someone mentioned cycling colors...

 :inspired:
Gave me a great idea for a simple addition to my own entry!
Title: Re: [LIQUID] Water3D
Post by: Pixel_Outlaw on March 08, 2010
Awesome stuff! Where is my full screen option? I plan to move to SDL soon myself.
Title: Re: [LIQUID] Water3D
Post by: Xalthorn on April 02, 2010
That's a good twist on the effect (every pun intended)
Title: Re: [LIQUID] Water3D
Post by: Praecor on April 11, 2010
Wow! Love its colors and the technical matrix looking effect style it has to it. Could make an entire long demo based around on this effect only!