Author Topic: [LIQUID] Water3D  (Read 6371 times)

0 Members and 1 Guest are viewing this topic.

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
[LIQUID] Water3D
« 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).
Challenge Trophies Won:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: [LIQUID] Water3D
« Reply #1 on: February 26, 2010 »
Ha!  Cool idea Optimus.

Looks really good.  :clap:
Challenge Trophies Won:

Offline Positron

  • C= 64
  • **
  • Posts: 93
  • Karma: 7
    • View Profile
Re: [LIQUID] Water3D
« Reply #2 on: February 26, 2010 »
Interesting idea. Looks good Optimus.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4380
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [LIQUID] Water3D
« Reply #3 on: February 26, 2010 »
Looking very good, buddy! Well done and thanks for the entry!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 977
  • Karma: 258
    • View Profile
Re: [LIQUID] Water3D
« Reply #4 on: February 26, 2010 »
Nice effect!  :)
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: [LIQUID] Water3D
« Reply #5 on: February 26, 2010 »
That is a very interesting idea. I never would have thought of it. The execution is very good. Nice entry.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: [LIQUID] Water3D
« Reply #6 on: February 26, 2010 »
very good :)

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: [LIQUID] Water3D
« Reply #7 on: February 26, 2010 »
Very nice - certainly a contender.
You are our 9001st visitor.
Challenge Trophies Won:

Offline janer

  • C= 64
  • **
  • Posts: 27
  • Karma: 1
    • View Profile
    • dAWNcreations
Re: [LIQUID] Water3D
« Reply #8 on: February 27, 2010 »
 :clap:
cool one!! this is just perfect for a background of a cracktro/intro!
dAWN!

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17376
  • Karma: 497
  • evil/good
    • View Profile
    • My Homepage
Re: [LIQUID] Water3D
« Reply #9 on: February 28, 2010 »
Very interesting looking effect Optimus :)

Thanks for posting it!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1289
  • Karma: 466
    • View Profile
    • my stuff
Re: [LIQUID] Water3D
« Reply #10 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.
Challenge Trophies Won:

Offline pixotica

  • ZX 81
  • *
  • Posts: 17
  • Karma: 4
    • View Profile
Re: [LIQUID] Water3D
« Reply #11 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.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: [LIQUID] Water3D
« Reply #12 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
You are our 9001st visitor.
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: [LIQUID] Water3D
« Reply #13 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).
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1289
  • Karma: 466
    • View Profile
    • my stuff
Re: [LIQUID] Water3D
« Reply #14 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.
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: [LIQUID] Water3D
« Reply #15 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.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [LIQUID] Water3D
« Reply #16 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
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1199
  • Karma: 229
    • View Profile
    • Homepage
Re: [LIQUID] Water3D
« Reply #17 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!
www.kirl.nl
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: [LIQUID] Water3D
« Reply #18 on: March 08, 2010 »
Awesome stuff! Where is my full screen option? I plan to move to SDL soon myself.
Challenge Trophies Won:

Offline Xalthorn

  • Amiga 1200
  • ****
  • Posts: 331
  • Karma: 100
    • View Profile
Re: [LIQUID] Water3D
« Reply #19 on: April 02, 2010 »
That's a good twist on the effect (every pun intended)
Challenge Trophies Won: