News for hackers. Stuff that matters.
Re:WebGL Water Simulator by Exuma on Saturday January 10, 2015 @05:19PM (#8868152)
Fun trick: Pause the simulation with the space bar. Then, take your mouse and drag it on the surface of the water, you will notice it creates ripples but in the paused state.

Drag the mouse rapidly back and forth in a very tiny area so that it creates a layered 'ripple' that grows and grows. If you spend about 2 minutes doing this you can make the ripple go like 10 feet high completely off the screen.

Then unpause the simulation for a massive tsunami.

Re:WebGL Water Simulator by JoshTriplett on Saturday January 10, 2015 @05:28PM (#8868174)
Rather than dragging, just click in the same spot hundreds of times to make a huge tower of water, then unpause to see a single ring of concentric waves and perfect wave reflection/interaction effects.
Re:WebGL Water Simulator by lifeformed on Sunday January 11, 2015 @04:26PM (#8871386)
Or paste this into the console:

     water.addDrop(x, y, radius, strength)
0,0 is the center, bounds are -1 to 1. 0.1 radius is a reasonable spike, 1 radius is a huge swell. 1 strength is really big. 10 is ridiculous. Try negative numbers too!

Try:

     water.addDrop(0, 0, 0.1, 5)
Re:WebGL Water Simulator by ca98am79 on Sunday January 11, 2015 @10:31PM (#8872366)
water.addDrop(5, 9, -0.03, 1) is cool, especially as it starts to settle
Re:WebGL Water Simulator by Exuma on Sunday January 11, 2015 @10:55PM (#8872426)
HOLY CRAP.... Dude
Re:WebGL Water Simulator by Rexxar on Sunday January 11, 2015 @07:30AM (#8869795)
If you click a lot, the level of water gets higher. Each click adds some water to the tank.

edit: The white sphere don't use the real level of water to decide where it should float (when gravity is activated)

Re:WebGL Water Simulator by 0942v8653 on Saturday January 10, 2015 @08:51PM (#8868733)
Or automate the process:

    for i in $(seq 1 100); do cliclick c:.; done
Re:WebGL Water Simulator by ldng on Saturday January 10, 2015 @07:52PM (#8868596)
But if you put the ball on half-way on the surface, it seems the water waves don't bounce on it. Or is it me ?
Re:WebGL Water Simulator by LukeB_UK on Saturday January 10, 2015 @08:12PM (#8868637)
If you do it in the middle, you get some really nice patterns
Re:WebGL Water Simulator by iamcreasy on Saturday January 10, 2015 @07:52PM (#8868594)
This was really really fun! :D
Re:WebGL Water Simulator by fatihpense on Saturday January 10, 2015 @08:52PM (#8868736)
I got a very nice heart shape by dragging: http://i.imgur.com/0675p4W.png
Re:WebGL Water Simulator by jsheard on Saturday January 10, 2015 @08:12PM (#8868638)
Doing this in a browser is a neat trick, but the actual state-of-the-art in realtime GPU fluids is slightly more impressive. nVidias FleX middleware is a good example:

https://www.youtube.com/watch?v=1o0Nuq71gI4

Re:WebGL Water Simulator by FrankenPC on Saturday January 10, 2015 @10:14PM (#8868897)
<= NOT a graphics programmer, in this era anyway. Back in my graphics days getting Phong shading working on a 286 was amazing to me.

So, does that Flex system BASICALLY imply that in another few decades the individual granularity of those particles will become so small and so numerous that we'll basically be modeling liquids and solids at the molecular level? It seems to me that it's only a lateral step then to mimic the fluid like effects of explosive forces being applied to solids.

Re:WebGL Water Simulator by Osmium on Sunday January 11, 2015 @10:14AM (#8870146)
> ... that in another few decades the individual granularity of those particles will become so small and so numerous that we'll basically be modeling liquids and solids at the molecular level?

Also not a graphics programmer, but I am a scientist who has model liquids and solids at the molecular level–a lot of this is doable today, but I doubt it'll ever be applied directly to a macroscopic graphics engine. There are quite simply too many atoms: there's 1 mole (6e23 atoms) in 18g of water. At best, todays chips have several billion transistors (5e9). Even at one transistor per molecule, the numbers just don't add up.

There are lots of multi-scale modelling techniques though, where you directly model the system on the atomic scale in just a few small volumes, e.g. at the tip of a crack just before it propagates. It's not impossible that sort of thing will make an appearance, though I'd still be surprised. Graphics programming is all smoke and mirrors; if it's easier to approximate something using an unphysical process that looks right, people will favour that over an exact simulation that takes far more computing power.

Re:WebGL Water Simulator by FrankenPC on Sunday January 11, 2015 @03:37PM (#8871201)
Yeah. You bring up an excellent point. Smoke and mirrors. It won't be molecular...not with semiconductors anyway. Maybe when quantum holographic systems are operating our transporters it will be possible :D.

UNTIL THEN, All it has to do is get granular enough to fill the resolution of the current generation of monitor technology. Just like how ray tracing really only requires enough granularity to appear seamless at the current resolution.

Re:WebGL Water Simulator by kruczek on Monday January 12, 2015 @08:21AM (#8873723)
Number of transistors is not really relevant here, since it still doesn't tell us anything about how many atoms we could simulate per second. If anything, we should be rather looking at FLOPS that can be generated by a given chip.
Re:WebGL Water Simulator by SixSigma on Sunday January 11, 2015 @03:12PM (#8871105)
My team made this back in 1996, on a Pentium Pro 180. I had to dump the frames off every 4 hours for three days straight. How things have changed.

https://www.youtube.com/watch?v=kU8pfwlPF4I

Re:WebGL Water Simulator by foobarian on Saturday January 10, 2015 @08:45PM (#8868715)
That video is breathtaking. I goofed off with N-body systems like probably most people and the size and performance of the systems shown there are light years ahead in comparison.
Re:WebGL Water Simulator by Exuma on Saturday January 10, 2015 @09:07PM (#8868758)
I love videos like this, do you know of any more good ones? I could watch this stuff all day.
Re:WebGL Water Simulator by jsheard on Saturday January 10, 2015 @09:34PM (#8868808)
Technical demos, or fluid dynamics eyecandy? Check out what the heavy duty non-realtime systems can do if you want the later.

https://www.youtube.com/watch?v=WD_K0Koi1MU

Re:WebGL Water Simulator by pimlottc on Sunday January 11, 2015 @02:03AM (#8869330)
Great stuff, but man, what a reality check. The most cutting-edge physics and graphics effects and it's used to sell beer and candy bars.
Re:WebGL Water Simulator by DanBC on Sunday January 11, 2015 @05:43AM (#8869632)
Some of those examples were clearly not real but some - the snickers bar being split - seemed pretty real.

I wonder if those very realistic shots are usable in UK adverts without disclaimers? As an example, see ads for mascara which get regulated if they use computer enhanced lashes and no disclaimer.

Re:WebGL Water Simulator by jsheard on Sunday January 11, 2015 @07:39AM (#8869812)
You might be surprised how fake the real thing can look:

https://www.youtube.com/watch?v=Ow-dDfarZuY

I'd say without a doubt that shots like 0:25 or 3:00 were CGI...

Re:WebGL Water Simulator by carlob on Sunday January 11, 2015 @05:37AM (#8869627)
Actually, I was once talking to a friend that does photography for print ads: I was surprised to find out that most of the highly detailed stills of, say, lipstick or champagne coming out of a bottle are actual photographs.
Re:WebGL Water Simulator by detaro on Sunday January 11, 2015 @07:11AM (#8869766)
Why were you surprised by that/How did you assume they were made otherwise?
Re:WebGL Water Simulator by carlob on Sunday January 11, 2015 @08:54AM (#8869968)
I assumed many things were renders or that stuff was combined later in photoshop.

I thought that champagne overflowing from a bottle was not made with real champagne over and over again until you got the perfect shot.

I was also surprised to find out that when the background had a nice motion blur it was sometimes actual motion blur made with a rotating rig that had the camera and the object to be shot on it.

Re:WebGL Water Simulator by aw3c2 on Sunday January 11, 2015 @06:06AM (#8869670)
Check out the annual Siggraph preview videos, https://www.youtube.com/results?search_query=siggraph+2014+p...
Re:WebGL Water Simulator by dsego on Saturday January 10, 2015 @05:42PM (#8868209)
Re:WebGL Water Simulator by FrankenPC on Saturday January 10, 2015 @10:05PM (#8868873)
Sanity check: Wasn't this posted on HN before?

Regardless. It's awesome that a browser with WebGL can achieve that kind of speed and behavioral complexity. Is ray tracing the reflections part of OpenGL? Or is that a separate library?

Re:WebGL Water Simulator by Kiro on Sunday January 11, 2015 @02:58AM (#8869405)
It has been posted several times before.
Re:WebGL Water Simulator by jrockway on Saturday January 10, 2015 @07:01PM (#8868472)
This is extremely well done.

The only minor nit I can come up with is the lack of surface tension. When you pull the ball up through the surface of the water, some of the water should stick to the ball. Maybe the ball is made out of lotus leaves, though.

I'd also expect some more bubbles when violently stirring the pool with the ball.

Re:WebGL Water Simulator by chengsun on Saturday January 10, 2015 @07:43PM (#8868576)
Unfortunately the effects that you describe are nontrivial. The method of water simulation that is used here doesn't lend itself to simulating the effects of things like water tension or breaking waves. This is because the water surface is represented as a 2D height-map, representing the displacement from equilibrium (i.e. the z coordinate as a function of x and y). It's clear that it is not possible to represent water clinging to the sphere or dripping off it.

A particle-based system could simulate the effects you describe (by keeping track of the positions of some large number of water "molecules" and exchanging forces between each pair of particles), however the simulation would be far too costly to run in real-time on typical hardware today. It also has its downsides. With a height-map based representation it is trivial to calculate the normal to the surface of the water, which is necessary for the lighting effects, but with a particle system you would need to reconstruct the surface of the water in an additional step each frame, using something like the marching cubes algorithm.

Re:WebGL Water Simulator by iamcreasy on Saturday January 10, 2015 @07:55PM (#8868602)
So the surface of the water is a real time displacement map?
Re:WebGL Water Simulator by zamalek on Monday January 12, 2015 @03:00AM (#8872883)
A real time calculated displacement map would be more appropriate. These simulations typically use real wave-front physics (Navier-Stokes), even if simplified.
Re:WebGL Water Simulator by Animats on Saturday January 10, 2015 @05:57PM (#8868257)
That's beautiful. I used to write physics engines back when we had 100 MIPS, and could only dream about doing stuff like that in real time.

A nice use for this would be to emulate a ripple tank, as used in high school physics labs.

Re:WebGL Water Simulator by boomskats on Saturday January 10, 2015 @07:04PM (#8868483)
I've been using this to test whether I've got WebGL acceleration working properly for ages. I'm pretty sure I've seen this posted a couple of times before though :)
Re:WebGL Water Simulator by ricardobeat on Saturday January 10, 2015 @08:41PM (#8868706)
Wow, this runs at a smooth 60fps in iOS8!
Re:WebGL Water Simulator by imaginenore on Saturday January 10, 2015 @07:00PM (#8868462)
This is 4 years old.
Re:WebGL Water Simulator by tdicola on Saturday January 10, 2015 @09:13PM (#8868765)
That's awesome, and holy cow I think this is the first time I've ever seen Chrome on Linux actually render WebGL. Did they finally enable it by default in recent updates?
Re:WebGL Water Simulator by iwince on Sunday January 11, 2015 @11:08AM (#8870277)
I've been playing with WebGL demos on Ubuntu for years, first Chrome then Firefox. It isn't new. You might also be impressed to find out that Steam is on Linux now too.
Re:WebGL Water Simulator by morganvachon on Saturday January 10, 2015 @10:08PM (#8868881)
I still have to enable it in chrome://flags as of the last official GNU/Linux release. It is enabled by default in Windows releases in my experience.
Re:WebGL Water Simulator by jpmonette on Saturday January 10, 2015 @08:04PM (#8868627)
Can't wait to see some more crazy stuff done in WebGL! Working fine on my MBA 2014, but I think it's the first time I heard the fan spinning :)!
Re:WebGL Water Simulator by frozenport on Saturday January 10, 2015 @06:04PM (#8868277)
On Android Firefox:

    Error: Rendering to floating-point textures is required but not supported.
Re:WebGL Water Simulator by jsheard on Saturday January 10, 2015 @06:23PM (#8868340)
Android Firefox and Chrome both implement the floating-point textures extension, but your devices GPU also has to natively support it.

If you're interested, you can check what your device supports with a tool like this: https://play.google.com/store/apps/details?id=com.darkrockst...

Not all of the GLES extensions will be exposed to WebGL, but most WebGL extensions directly map to a GLES one (GL_OES_texture_float in this case).

Re:WebGL Water Simulator by WallWextra on Saturday January 10, 2015 @10:04PM (#8868870)
On a Galaxy S5, it works glitchily in Chrome and not at all in Firefox.
Re:WebGL Water Simulator by jsheard on Saturday January 10, 2015 @10:19PM (#8868907)
Maybe Mozilla blacklisted the extension: Qualcomm drivers are apparently quite awful.

https://dolphin-emu.org/blog/2013/09/26/dolphin-emulator-and...

Re:WebGL Water Simulator by serf on Saturday January 10, 2015 @06:18PM (#8868318)
same on Firefox Developer Edition 36.0a2 (2015-01-10).
Re:WebGL Water Simulator by S_A_P on Saturday January 10, 2015 @10:12PM (#8868892)
I remember trying to run this on my phone previously and it not working. I also remember it causing my cup fan to fire up when I played with it on my laptop. The fact that the iPhone 6 runs this so well is pretty dang cool.
Re:WebGL Water Simulator by vhost- on Saturday January 10, 2015 @11:19PM (#8869002)
Same here! I remember trying it on an older iPhone and android phone and it was choppy. Just tried it on my iPhone 6 and it's so smooth. I love seeing that progression in technology first hand.
Re:WebGL Water Simulator by rndn on Saturday January 10, 2015 @07:03PM (#8868478)
Does anyone happen to know what the effect is called that the sky is reflected stronger at shallow angles and whether that is the same effect which makes rough surfaces reflective at very shallow angles?
Re:WebGL Water Simulator by sibsibsib on Saturday January 10, 2015 @07:25PM (#8868526)
Re:WebGL Water Simulator by shurcooL on Saturday January 10, 2015 @07:01PM (#8868470)
> This demo requires a decent graphics card and up-to-date drivers. If you can't run the demo, you can still see it on YouTube.

Works great on my iPad mini 2. Pretty incredible.

Re:WebGL Water Simulator by slacka on Saturday January 10, 2015 @09:54PM (#8868851)
Yes it does. I'm SOL. On my SGS3 with both Chrome and FF I get:

    Error: Rendering to floating-point textures is required but not supported.
 
And on my Ubuntu 14.10 laptop with X1400 I get:

    Uncaught Error: link error: error: Too many vertex shader texture samplers
Re:WebGL Water Simulator by cracker_jacks on Saturday January 10, 2015 @09:40PM (#8868816)
Shouldn't the ball cause ripples when moving underwater?
Re:WebGL Water Simulator by snowwrestler on Saturday January 10, 2015 @10:41PM (#8868950)
It looks like it's only simulating the surface. Moving a ball that of that relative size in that volume of water would cause all sorts of surface features, if the full volume of water was being simulated.
Re:WebGL Water Simulator by guidedlight on Saturday January 10, 2015 @05:50PM (#8868237)
Surprisingly, this demo works great on my iPad 4.
Re:WebGL Water Simulator by bobajeff on Saturday January 10, 2015 @06:17PM (#8868311)
Yeah, I just tested it on my mid-range android phone with Chrome. It works surprisingly well, though it lags a bit it's still usable. Really all webgl stuff should work on mobile since it was designed with that in mind. Ironically it probably wouldn't work on my old desktop with the Directx9 capable nvidia card.
Re:WebGL Water Simulator by cturhan on Sunday January 11, 2015 @05:46AM (#8869639)
I think this was the fourth duplicate post here
Re:WebGL Water Simulator by Kenji on Saturday January 10, 2015 @07:45PM (#8868579)
This is an old piece but it doesn't cease to amaze me. Well done, creating this must have taken a lot of time and skill.
Re:WebGL Water Simulator by josephpmay on Saturday January 10, 2015 @05:13PM (#8868137)
The author of this simulation seems to have forgotten the effects of refraction. Besides that, it's great!
Re:WebGL Water Simulator by JoshTriplett on Saturday January 10, 2015 @05:25PM (#8868164)
Refraction definitely works; try moving the camera around, and you can see the effects of refraction on the ball.
Re:WebGL Water Simulator by josephpmay on Saturday January 10, 2015 @05:44PM (#8868217)
It appears to work on the top but not on the sides
Re:WebGL Water Simulator by Mikeb85 on Saturday January 10, 2015 @05:52PM (#8868240)
The sides seem to be a cut-away view, not a surface...
Re:WebGL Water Simulator by JoshTriplett on Saturday January 10, 2015 @07:08PM (#8868493)
Right. Refraction only occurs on the surface of the water, like the waves; the views through the sides are what you'd see from under the water at that point, not looking through a viewing window.
Re:WebGL Water Simulator by DannyBee on Sunday January 11, 2015 @01:37AM (#8869271)
Well, if you want to get really technical, what you'd see from underwater would be much worse than what a camera sees, since your eyes require air to properly focus.

So if they wanted to make it what you would see underwater, they should just blur the crap out of it.

Re:WebGL Water Simulator by frozenport on Saturday January 10, 2015 @06:30PM (#8868365)
Are you talking about total internal reflection? http://upload.wikimedia.org/wikipedia/commons/5/5c/Total_int...

I think I can find an angle where you can't see the skybox.

Re:WebGL Water Simulator by elberto34 on Saturday January 10, 2015 @06:46PM (#8868415)
does this use the navier stokes equations? How are the ripples generated?
Re:WebGL Water Simulator by constexpr on Saturday January 10, 2015 @07:06PM (#8868489)
Nope, it's much simpler than that. It's just a grid of vertical positions and each frame every cell moves toward the average position of the neighbors from the previous frame. See http://freespace.virgin.net/hugo.elias/graphics/x_water.htm for details.
Re:WebGL Water Simulator by izo on Sunday January 11, 2015 @01:24PM (#8870687)
Wow. It's amazing to see how far WebGL has come.
Re:WebGL Water Simulator by ummonkwatz on Sunday January 11, 2015 @02:22PM (#8870930)
So close to a WebGL Wave Race!
Re:WebGL Water Simulator by snooze82 on Saturday January 10, 2015 @05:39PM (#8868201)
you can even move the ball.
Re:WebGL Water Simulator by sand500 on Saturday January 10, 2015 @08:50PM (#8868731)
if you drag the ball round and round, it doesnt create a votex.