News for hackers. Stuff that matters.
Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @03:30AM (#3366265)
Definitely not. The performance is pathetic, the feature set is pretty basic.

WebGL is where compiled 3d apps/games were, like, 20 years ago. Yes, I know it will improve, but so will compiled products. The sheer fact that WebGL is interpreted and is a poor-man's subset of OpenGL, puts it at permanent disadvantage.

Of course, you could have some trick allowing for compiled graphics code to be run within the browser, analogous to the Chrome Native Client, and with all the DirectX/OpenGL features. But that's no longer WebGL, that's just a smart trick to run old-school code within the confines of a browser environment. You might just as well write a stand-alone app.

Re:Is WebGL the future? by irrlichthn on Sunday December 18, 2011 @03:38AM (#3366273)
20 years ago? That was the time of Wolfenstein 3D. :) Much more thant that is possible with WebGL... Take a look at some of those demos available. (example: http://www.ambiera.com/copperlicht/demos.html) You can always workaround that performance problem. No need to program some CPU cylcle swallowing AI for now.
Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @05:08AM (#3366362)
Well, maybe 20 years was too far of a shot. But I assume you're associated with the Irrlicht game engine, so I assume that when you write "is WebGL the future?", you don't mean "will it be useful at all?" or "will some silly casual games be possible in WebGL?", but whether it will be a legitimate gaming platform, capable of competing with desktop gaming (which is where Irrlicht competence lays, afaik).

And to that I say firmly: no.

I like the demos you've linked to (and I've seen them before), no doubt they're quite impressive, considering the constraints of the browser environment.

But when I put them in context of what one could run on a computer natively, these demos remind me of Quake I. Sorry.

Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @07:33AM (#3366516)
And BTW, I really hate to put you down like this. I have dreams of my own of one day writing an MMO game, that would mostly be handled by a server and the client would run in a browser. Perhaps the clue is not BF3-level graphics, but something "decent" on the graphical side and a really cool world and mechanics within the game.

I'm just a little frustrated at how inefficient all this web stuff still is. Imagine even your own demos - rather simple graphics by native standards - but with much larger world and many more characters. It would grind to a halt even on a mid-range PC, not to mention an iPad or a cheap laptop.

Still, I really wish that you create a plug-and-play graphics engine for web game developers, that would allow people like me to fulfill their fantasies. :) Wish you all the best!

Re:Is WebGL the future? by gacek on Sunday December 18, 2011 @03:55AM (#3366290)
WebGL is not a poor-man's subset of OpenGL, its the same subset that is supported by most mobile devices (OpenGL ES2.0). What are you missing? Quads? 3D textures? NURBS?

And yes, we know that JS is interpreted and that it's no use for building anything more than a clock on your webpage, right?

Re:Is WebGL the future? by exDM69 on Sunday December 18, 2011 @07:02AM (#3366475)
>> WebGL is not a poor-man's subset of OpenGL, its the same subset that is supported by most mobile devices (OpenGL ES2.0).

WebGL is just that, a poor-man's subset of OpenGL. As is OpenGL ES 2, which is a standard that's deprecating very fast as mobile GPU's pack more and more kick-ass.

OpenGL ES standardization efforts are badly left behind the development, as graphics vendors are adding more and more extensions to GLES in their implementations. These extensions tend to be a little stripped down versions of desktop GL features and the worst thing is that they're not quite compatible with desktop GL or even similar extensions form other vendors. Next version of GLES (codename "Halti") has to be standardized pretty fast or it will be out of date by the time it comes out.

If you want to write high quality 3d games or graphics using GLES2, you will have to use vendor specific extensions and write code specifically for the devices you intend to ship on. If you're doing something very basic, you may get away with using only the features in GLES2, but you'll still have to consider how to match the performance to the wide array of GLES2 conformant devices out there. It also helps if you're a part of a major graphics vendor's developer partnership program, like it or not.

WebGL's standardization cycle probably even slower. It took a while for the spec to reach maturity and major browsers implementing it. AFAIK, there's no extension mechanism to gain access to not-yet-standardized features. When the next version of OpenGL ES comes out, how long will it take for it's new features to come available to WebGL? Is the WebGL API even designed for extendability? Who are the industry players willing to contribute their engineering efforts to building WebGL specs and implementations?

Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @05:04AM (#3366361)
Could you write (graphically) Battlefield 3 in WebGL, assuming you'd be able to compile it to run efficiently?

As for your second question, JS is very useful, I love JS, I write 90% of my code in JS. But we're talking sophisticated 3d apps here, not whether it's useful at all.

Re:Is WebGL the future? by fridek on Sunday December 18, 2011 @05:22AM (#3366379)
Yes you can. Have you seen Team Fortress 2 in WebGL?

http://www.youtube.com/watch?v=DQrC5YLKFUY

http://www.youtube.com/watch?v=Lmvj6-CFbbA

JS is not very pleasant to code with, so writing an actual game logic could be a bit painful, but so is development for PS3 and it's done somehow. It's not a question of performance, rather about workflow and structures provided by language.

Re:Is WebGL the future? by ehsanu1 on Sunday December 18, 2011 @06:49AM (#3366452)
JS has gotchas and some really bad parts, but if you know the language well and know what you're doing, I think it's quite pleasant actually for many problems. Have you done much programming with JS, and if so, what was so unpleasant about it?

Though, I think I've heard pretty much all the complaints against JavaScript, many of which are addressed by using something like CoffeeScript.

Re:Is WebGL the future? by fridek on Sunday December 18, 2011 @06:58AM (#3366469)
I'm using Google Closure to get rid of the bad parts, but still it's not very good. I did some testing with game AI, graphics and so on - JS is far from perfect for such things. Maybe it's a lack of tools, maybe of some features I was used to in C++ or maybe it's that all the books and tutorials are targeted for C++.

It doesn't really matter, browser games are the future and no matter how complicated it's going to be, somebody will be good enough to write them. We already passed "demo era" and some games are really good, like https://chrome.google.com/webstore/detail/bhoaojooagiaaiidln...

Re:Is WebGL the future? by voyytek on Sunday December 18, 2011 @05:23AM (#3366380)
But why do you need to write BF3? There are tons of games besides 3D shooters. Could you write minecraft in WebGL? I bet.
Re:Is WebGL the future? by exDM69 on Sunday December 18, 2011 @07:05AM (#3366479)
>> WebGL is where compiled 3d apps/games were, like, 20 years ago.

20 years is a bit of exaggeration. Doom 1 was released 20 years ago.

Feature-wise WebGL/GLES2 matches a desktop GPU circa 2004 or so. Doom 3-ish feature set. Performance wise it's a bit behind, but this varies so much from device to device that it makes no sense to take this into a discussion when we're talking about API standards and their features.

Re:Is WebGL the future? by nextparadigms on Sunday December 18, 2011 @03:47AM (#3366279)
I think Native Client is pretty impressive if you want to make a browser-game. Bastion looks pretty good:

https://chrome.google.com/webstore/detail/oohphhdkahjlioohba...

Re:Is WebGL the future? by kevingadd on Sunday December 18, 2011 @03:54AM (#3366288)
WebGL is interpreted? What do you mean? Modern JavaScript runtimes are DEFINITELY not interpreted, and the idea of an interpreted graphics API or GPU is nonsense.
Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @04:58AM (#3366351)
LOL, what is JavaScript then, if not interpreted?

I'm not going to get into a semantic argument, perhaps to you Java is not interpreted either, but to me anything that doesn't compile to a binary directly executable on the CPU is substandard in terms of performance. And I'm sorry to surprise you, but in 3d graphics we're still starved for processor cycles, otherwise we'd have ray-traced, globally illuminated games with huge environments to play with.

Re:Is WebGL the future? by fridek on Sunday December 18, 2011 @05:09AM (#3366365)
It's JIT compiled and WebGL shaders are compiled as well. It is a native code executable on CPU, read how Crankshaft in V8 works. It's true that JS is at the moment N times slower than C++ (N in range 1 to 10). It's not true that you need to use JS that much to have great graphics. Everything you pointed out is done on GPU afaik. And if you wait a year or so, JIT + type inference will make JS basically as fast as C++.
Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @07:18AM (#3366495)
Well, I'm not that familiar with the internals of JS engines, perhaps some browsers are capable of partial compilation. On the other hand, this is a dynamic language (as in: data types and other pieces of code can change in run-time), with limited features, like data structures (wanna benchmark linked lists or kd-trees in C++ vs JS? I doubt N=10 is skeptic enough). I'm not sure if I write path-finding or collision detection or line-triangle intersection with their respective data structures in JS, it will turn out anywhere in the ballpark of real compiled code. (And this is pretty elementary stuff in 3d games.)
Re:Is WebGL the future? by fridek on Sunday December 18, 2011 @07:29AM (#3366511)
Now we are getting somewhere ;) Graphics are not an issue, physics may be. Still, you would be surprised how fast compiled JS can be. It requires some discipline but if your code is good, performance is not that bad. And some data structures are actually waaay easier and smaller in JS (e.g. graphs). These are pros and cons of high level language.

By the way, there are also typed arrays which are translated directly to native code and were designed with WebGL in mind. I'd say that garbage collector is now the biggest issue of JS games. But it's improving, don't be skeptic.

EDIT: Actually, I did a small lecture a week ago, about performance tips. It's probably far from perfect as I don't work on browser engines, but it may give you some hints about making JS performance C++-like. http://www.smashinglabs.pl/lectures/js-performance/

Re:Is WebGL the future? by hastur on Sunday December 18, 2011 @07:49AM (#3366537)
Graphics is very much an issue. Look at the web demos of the Irrlicht guys: http://www.ambiera.com/copperlicht/demos.html

I'd say that's an absolute minimum in terms of sophistication. And yet, some of it barely runs on a modest hardware setting. (Core2duo 2.5GHz, GF 8600GT.) [EDIT: Well, OK, in Chrome it runs OK, but still, these are tiny windows. Full-screen wouldn't be so nice.]

Now, imagine that you want to write an MMORPG. You make it just a little prettier than those demos, but more importantly - expand the world and add many more characters. It would bring _any_ gaming rig to a halt. (And yes, I realize that you don't display the whole world at once. But still, you need much more than there is on these demos.)

I dzięki za linka, fajne rzeczy na SmashingLabs i AiGameDev. :]

Re:Is WebGL the future? by fridek on Sunday December 18, 2011 @08:37AM (#3366591)
These demos run perfectly well on my Intel card. There are also interactive music videos like http://www.ro.me/ or http://lights.elliegoulding.com/ which are running fast enough. OpenGL ES is almost the same as OpenGL, the only feature I've found missing so far was geometry shader.

What in my opinion stops graphics from being better is model size that has to be transferred. You wouldn't wait 2 hours for game to load, would you?