Live data from Hacker News

Web GL Ocean Simulation

david.li

71–80 of 138 posts

Re: Web GL Ocean Simulation

#71
post #66
post #46

Earlier quoted context omitted.

It is actually linear. a,b,c,d are the unknowns and x1 and x2 are the inputs. A bit confusing since normally x1,x2 denote the unknowns.

Unless you like econometrics: then X are data, betas and gammas and sigmas are unknown (oh my!). Jargon is fun, unless I want to communicate across fields :/.

Well today I learned. I never knew that. Stupid mathematics and its inconsistent notation.

Re: Web GL Ocean Simulation

#72

I remember seeing this run smoothly on a P2 after a very small executable download in late 90's. How far we've come in a big, stupid circle back where we started. Now instead of a small executable, we need a large executable to sit on top of a large API on top of the CPU before even touching the GPU, and a network connection to download all the dependant APIs and libraries every time the page is loaded. The only impr…

People value being not having to manually download and install software. You can either take advantage of this, or you can complain about it.

Re: Web GL Ocean Simulation

#73
post #35

The code is quite cool to look at. Love seeing the extensive use of matrices and mathematics to create such a beautiful and mesmerizing display. If anyone is interested in playing around with it, I threw it up at JSFiddle here: http://jsfiddle.net/zyAzg/ Excellent demo.

Just to clarify - the bulk of the work here is done in GLSL shaders on the GPU, not with matrices in JavaScript. All that matrix code you see in the source here is basically just the minimum prerequisite for doing 3D graphics, it would be the same if you just wanted to get a spinning cube with some camera control. The real magic happens in the shaders which compute water mesh displacement, normals and shading directl…

this is magic? isn't this precisely what the hardware was designed for? i wouldn't call this GPGPU personally - this is very much graphics.

GPGPU is more about e.g. doing multi-precision integer arithmetic on the GPU - where the processors are used for something which doesn't fit the 'streaming processor being fed vectors' pattern which the architecture was made for (of which this demo is a very good example) - quite literally 'general purpose'.

Re: Web GL Ocean Simulation

#74
Might be system dependent, though couldn't help but notice a non-trivial difference in the OpenGL rendering quality, between Firefox and Chrome.

Chrome 32 beta on OS X, produced an anti-aliased canvas, whereas Firefox 25 had the dreaded jaggies @ 1680x1050

Re: Web GL Ocean Simulation

#75
post #73
post #35

Earlier quoted context omitted.

Just to clarify - the bulk of the work here is done in GLSL shaders on the GPU, not with matrices in JavaScript. All that matrix code you see in the source here is basically just the minimum prerequisite for doing 3D graphics, it would be the same if you just wanted to get a spinning cube with some camera control. The real magic happens in the shaders which compute water mesh displacement, normals and shading directl…

this is magic? isn't this precisely what the hardware was designed for? i wouldn't call this GPGPU personally - this is very much graphics. GPGPU is more about e.g. doing multi-precision integer arithmetic on the GPU - where the processors are used for something which doesn't fit the 'streaming processor being fed vectors' pattern which the architecture was made for (of which this demo is a very good example) - quite…

Most people wouldn't have thought of using graphics hardware to do physical simulation, especially of fluids.

Re: Web GL Ocean Simulation

#76
post #48

Earlier quoted context omitted.

In case that the exact formulas for this solution would be numerically unstable, why would the LU decomposition improve the numerical stability? Also, why should it be faster? Well, to be fair, in that example, if the compiler does those `pow(x2 - x1, 3.)` calls multiple times, this would not be optimal, but otherwise, it should be ok. I did this because I will probably never ever change the matrix A here and I wante…

I'm not implying yours are not unstable, it's just there is a chance it might be. Typically exact formulas exhibit such properties. LU decomposition is numerically stable, for the most part. You can run into problems with floating point arithmetic if you're not careful. This just has to do with the way you solve the problem. By breaking up the matrix into an upper and lower triangular part and solving the resulting t…

Wait, no, LU decomposition is not stable unless you're doing pivoting. And if you're doing pivoting, then it very much stops looking like an "exact formula", because it'll get filled up by ifs and variable renamings, etc.

There's plenty of cases in graphics and simulation where solving even a 4x4 matrix needs careful numeric consideration (see this paper about tetrahedral mesh simplification, section III.D, page 7: http://www.sci.utah.edu/~hvo/papers/tetstream.pdf)

If you care about accuracy at all, do not use the straightforward "exact formulas" like Cramer's rule. That's just asking for trouble.

And for numerical linear algebra, I'd go start with Strang and chapter 9: http://math.mit.edu/linearalgebra/

Re: Web GL Ocean Simulation

#77
post #70

computers have now become so powerful that this stuff is easy. you can implement it in a way which, aside from platform, is really quite naive and wasteful - and still get applause. most programmers can come up with a much better solution to this problem if removed from google and forbidden access to gpu gems. this is at least well presented though... its a shame the code has been posted. whilst i normally assume tha…

"most programmers can come up with a much better solution to this problem if removed from google and forbidden access to gpu gems." I doubt I could come up with such a solution even with access to google and gpu gems. I am not a particularly good programmer, but I know for certain that most programmers wouldn’t even know where to begin to implement something like this.

Re: Web GL Ocean Simulation

#78
post #75
post #73

Earlier quoted context omitted.

this is magic? isn't this precisely what the hardware was designed for? i wouldn't call this GPGPU personally - this is very much graphics. GPGPU is more about e.g. doing multi-precision integer arithmetic on the GPU - where the processors are used for something which doesn't fit the 'streaming processor being fed vectors' pattern which the architecture was made for (of which this demo is a very good example) - quite…

Most people wouldn't have thought of using graphics hardware to do physical simulation, especially of fluids.

i'm not sure where to start here...

actually this is exactly what everyone thought when this hardware was new 10 years ago... and even before that we were thinking about it. look at rendering demos from that time that leveraged the shader - this was the dumbass obvious thing that almost everyone did.

this is not physical simulation - not even close. the navier-stokes equations are still really quite difficult to do anything real-time with unless you make some serious compromises.

i will conceded that this is very loosely based on physical reality. but actually, you can do a lot, /lot/ better with clever hacks.

as an example of one of the much, much better solutions which approximate reality than this - the old school 2d 'water' effect created from feedback and a clever 3x3 convolution filter shaped as a ring with a hole in the middle, for instance is visually much more impressive and computationally simpler - and it actually is a solution to a discretised wave equation. render this old effect as greyscale into a buffer than use it as a height/displacement-map style texture - with this solution implementing real-time ripples and fluid like response to objects entering the liquid comes down to rendering the outline into that buffer and these kinds of waves simply fall out rather than requiring maintenance or trig calls...

Re: Web GL Ocean Simulation

#79

> Your browser does not appear to support the required technologies. It would've been nice to have an 'I don't care, proceed anyway' button. The check excludes Safari 7, which runs the demo just as well as Chrome. http://jsfiddle.net/bYHfh ^ removes the hasWebGLSupport() invocation. Very nice demo, though!

Is there a google chrome extension that allows me to modify the served javascript from the original page?

Re: Web GL Ocean Simulation

#80
post #70

computers have now become so powerful that this stuff is easy. you can implement it in a way which, aside from platform, is really quite naive and wasteful - and still get applause. most programmers can come up with a much better solution to this problem if removed from google and forbidden access to gpu gems. this is at least well presented though... its a shame the code has been posted. whilst i normally assume tha…

"most programmers can come up with a much better solution to this problem if removed from google and forbidden access to gpu gems." I doubt I could come up with such a solution even with access to google and gpu gems. I am not a particularly good programmer, but I know for certain that most programmers wouldn’t even know where to begin to implement something like this.

don't be so doubtful. i started out down this path without google and the internet so its especially easy for me to see, but consider: do you even want to make this?

if you did i'd bet you'd find a way - google, wikipedia and free copies of gpu gems make it stupidly easy. the amount of understanding required to produce a demo like this is no more than is required to copy someone else's code or algorithm in any other discipline.

even without those, if you wanted to make this i bet you could come up with something pretty good on a first attempt. even now i bet that somewhere in there you have a pretty good idea of an approach - you might think its dumb, inefficient or must have a flaw in it - you might have no idea about what you need to feed the rendering pipeline - but i'd bet its pretty good - probably a lot better than you'd give it credit for.

Post reply on HN