News for hackers. Stuff that matters.
Re:WebGL Water by rdtsc on Wednesday February 19, 2014 @11:41AM (#7264452)
What is the future of WebGL? I have seen cool demos but is this the way forward. So one has a game to develop or a complicated visualization, is it worth investing time in learning WebGL or try to use Canvas directly.
Re:WebGL Water by daredevildave on Wednesday February 19, 2014 @11:51AM (#7264513)
If you just want to make a game, you may not want to bother learning WebGL directly. You can use an engine like PlayCanvas[1]* to build a game and you don't have to worry about the low-level stuff.

[1] https://playcanvas.com/

*I'm a co-founder

Re:WebGL Water by superqd on Wednesday February 19, 2014 @01:18PM (#7265108)
Very cool stuff.
Re:WebGL Water by petercooper on Wednesday February 19, 2014 @11:45AM (#7264476)
WebGL is essentially a specialized OpenGL-ES based context of canvas. HTML5 canvas in its usual context is only for 2D. You can render 3D on it but you'll essentially be creating your own software rendering engine from scratch.
Re:WebGL Water by rdtsc on Wednesday February 19, 2014 @12:23PM (#7264714)
So then my question is what is the future of WebGL?

I could see canvas extended to have 3D operations. Like say draw point takes 3 coordinates now. I can see a third party library that does 3D but projects it down to 2D and uses regular 2D commands on the canvas, or I see supporting WebGL interface and writing OpenGL style code.

Re:WebGL Water by _greim_ on Wednesday February 19, 2014 @01:35PM (#7265237)
> I could see canvas extended to have 3D operations. Like say draw point takes 3 coordinates now.

I think that's the role WebGL essentially fulfills. It was just done in a way that uses OpenGL instead of reinventing the wheel, since a 3D rendering engine is a non-trivial thing to build. In other words, you can do either:

    var ctx = myCanvas.getContext('2d');
    // ctx has the 2d api

    var ctx = myCanvas.getContext('webgl');
    // ctx has the webgl 3d api
> I can see a third party library that does 3D but projects it down to 2D and uses regular 2D commands on the canvas.

I think it would be a lot slower. Either way there's a 3D rendering engine. Embedding the engine natively and having GPU speedups is a dominating factor.

> or I see supporting WebGL interface and writing OpenGL style code.

See first point above.

Re:WebGL Water by etherealG on Wednesday February 19, 2014 @01:05PM (#7265018)
I think the suggestions of using a lib to get higher level stuff are good ones. For simple enough stuff, d3, or more complex whole game engines are available.
Re:WebGL Water by gmac on Thursday February 20, 2014 @05:10AM (#7269985)
http://threejs.org/ may be relevant.
Re:WebGL Water by nairteashop on Wednesday February 19, 2014 @01:27PM (#7265171)
It's a good question. I have an entire bookmark folder of "cool WebGL demos" collected over the years, but have seen very few full-fledged applications.

One way you could hedge the WebGL vs. Canvas bet is to use something like THREE.js, where you use THREE's cameras, lighting, etc and then specify whether it should use WebGL or Canvas for rendering. But then again, you'd be betting on THREE.js :)

https://github.com/mrdoob/three.js/

Re:WebGL Water by AshleysBrain on Wednesday February 19, 2014 @01:49PM (#7265337)
WebGL is not just for 3D: it can be used for 2D games, where it is way faster than ordinary canvas2d, and allows use of shader effects and such. Major web game engines like Construct 2 [disclaimer: I am developer] use WebGL rendering with effects, and fall back to canvas2d if WebGL is not supported. So at least with Construct 2, it's been in commercial production use for a couple of years already.
Re:WebGL Water by TazeTSchnitzel on Wednesday February 19, 2014 @01:28PM (#7265178)
Worth noting that only the WebGL renderer has normal FPS.
Re:WebGL Water by superqd on Wednesday February 19, 2014 @01:17PM (#7265096)
It's a pretty bright future for WebGL. Lots of companies are doing 3D visualization on the web, including the one I work for. Our product includes an embedded web based architectural model 3D viewer (written by myself and one other dev).

So there are definitely companies making serious use of it.

Re:WebGL Water by Joeri on Wednesday February 19, 2014 @03:16PM (#7265924)
Interesting producr. I've been looking into BIM integration for the FM software suite I work on, and the possibility of embedding a webgl BIM viewer to match our existing SVG-based CAD viewer. It seemed like a lot of work though to get it running properly (it seemed like one of those things where you can get a demo going in a matter of hours but finishing it up takes months).
Re:WebGL Water by superqd on Friday February 21, 2014 @10:29AM (#7277366)
You are correct. One of our devs built a prototype using a 3rd party WebGL framework quickly (few days), but for the real deal, we started over and went straight to WebGL ourselves (so we could better optimize for large models, etc). The prototype that was built just couldn't handle models of any meaningful size, so we definitely needed to own everything about the code so we could optimize for our needs.

We are in the BIM space and have one of the few web based viewers for such models. Some other products require a plugin to render 3D, but we really wanted to reduce friction to use our product, so we decided to go with WebGL. It's now supported in all 3 major browsers too.

Re:WebGL Water by thejefflarson on Wednesday February 19, 2014 @07:58PM (#7267992)
That depends. At ProPublica we've done a bunch of visualizations with canvas and SVG in the past, and they are powerful tools. However, as part of our investigation into Hurricane Sandy flooding we knew we wanted to make a 3D visualization of NYC of show the storm surge:

http://projects.propublica.org/nyc-flood/

If your data is inherently 3 dimensional I'd say it is worth the effort to dive in, but the majority of visualizations that we do are charts and plots which don't really need to be 3D.

Re:WebGL Water by higherpurpose on Wednesday February 19, 2014 @11:53AM (#7264524)
There's a WebGL2 spec in the works, but not sure if it's based on OpenGL ES 3.0 or 4.0/Next. Since it's taking so long to finish it, I'm hoping it's the latter, since 3.0 didn't bring that many improvements, and ES 4.0/Next/whatever they want to call it is supposed to launch soon, I think.
Re:WebGL Water by frik on Wednesday February 19, 2014 @01:44PM (#7265301)
WebGL 2 Specification: http://www.khronos.org/registry/webgl/specs/latest/2.0/ (Editor's Draft 26 September 2013)

  [...] API that conforms closely to the OpenGL ES 3.0 API.
Re:WebGL Water by CmonDev on Wednesday February 19, 2014 @12:34PM (#7264795)
You can use something that is not browser-specific (since WebGL is not a part of HTML5), such as Unity instead.
Re:WebGL Water by TazeTSchnitzel on Wednesday February 19, 2014 @12:09PM (#7264615)
WebGL is using canvas directly, it's the 3D canvas API.
Re:WebGL Water by rdtsc on Wednesday February 19, 2014 @12:19PM (#7264679)
Ok so if it is using canvas directly why bother calling it WebGL and why does it not run on some machine on Linux based on availability of certain graphics drivers?

If it was based on canvas and using that directly I would expect it to be an add-on library that takes a 3D scene for example and translates it to a 2D canvas commands.

It seems it is doing more than that though...

Re:WebGL Water by bskap on Wednesday February 19, 2014 @12:22PM (#7264711)
Because it's using the graphics card to convert the 3D instructions into 2D equivalents in real-time. You can't calculate that stuff ahead of time if you want to allow the user to manipulate the canvas. And the whole reason we have graphics cards in the first place is because doing that on the CPU is too slow.
Re:WebGL Water by rdtsc on Wednesday February 19, 2014 @12:28PM (#7264750)
Well I've seen some demos and games of people using a 2D canvas to show a 3D scene.

Back in the day computers didn't have 3D accelerated cards, it was all done on the CPU and there were enough 3D games that ran on them.

I can also see canvas API extended to have 3D operations on it.

It just seems WebGL is (was?) popular, lots of demos, but I still haven't seen too many industry uses of it and I have heard people at work claim "it is dead". So I was just wondering, ok, if it is dead is there any hope of having 3D accelerated graphics in the browser or is there something else replacing it.

* It seems a sibling comment answered my question:

https://news.ycombinator.com/item?id=7264524

Re:WebGL Water by nitrogen on Wednesday February 19, 2014 @06:18PM (#7267343)
Reposting this dead comment both to indicate agreement and alert the commenter:

IE5point5 50 minutes ago | link [dead]

> and I have heard people at work claim "it is dead".

Then people at your work are clueless I'm afraid

-----

My own startup's products use WebGL for simple GPU-accelerated 2D image operations (Bayer demosaicing). It even works on my Android phone.