Tag Archives: OpenGL ES

Why use WebGL for Graphics Research?

guest post by Patrick Cozzi, @pjcozzi.

This isn’t as crazy as it sounds: WebGL has a chance to become the graphics API of choice for real-time graphics research. Here’s why I think so.

An interactive demo is better than a video.

WebGL allows us to embed demos in a website, like the demo for The Compact YCoCg Frame Buffer by Pavlos Mavridis and Georgios Papaioannou. A demo gives readers a better understanding than a video alone, allows them to reproduce performance results on their hardware, and enables them to experiment with debug views like the demo for WebGL Deferred Shading by Sijie Tian, Yuqin Shao, and me. This is, of course, true for a demo written with any graphics API, but WebGL makes the barrier-to-entry very low; it runs almost everywhere (iOS is still holding back the floodgates) and only requires clicking on a link. Readers and reviewers are much more likely to check it out.

WebGL runs on desktop and mobile.

Android devices now have pretty good support for WebGL. This allows us to write the majority of our demo once and get performance numbers for both desktop and mobile. This is especially useful for algorithms that will have different performance implications due to differences in GPU architectures, e.g., early-z vs. tile-based, or network bandwidth, e.g., streaming massive models.

WebGL is starting to expose modern GPU features.

WebGL is based on OpenGL ES 2.0 so it doesn’t expose features like query timers, compute shaders, uniform buffers, etc. However, with some WebGL 2 (based on ES 3.0) features being exposed as extensions, we are getting access to more GPU features like instancing and multiple render targets. Given that OpenGL ES 3.1 will be released this year with compute shaders, atomics, and image load/store, we can expect WebGL to follow. This will allow compute-shader-based research in WebGL, an area where I expect we’ll continue to see innovation. In addition, with NVIDIA Tegra K1, we see OpenGL 4.4 support on mobile, which could ultimately mean more features exposed by WebGL to keep pace with mobile.

Some graphics research areas, such as animation, don’t always need access to the latest GPU features and instead just need a way to visualization their results. Even many of the latest JCGT papers on rendering can be implemented with WebGL and the extensions it exposes today (e.g., “Weighted Blended Order-Independent Transparency“). On the other hand, some research will explore the latest GPU features or use features only available to languages with pointers, for example, using persistent-mapped buffers in Approaching Zero Driver Overhead by Cass Everitt, Graham Sellers, John McDonald, and Tim Foley.

WebGL is faster to develop with.

Coming from C++, JavaScript takes some getting use to (see An Introduction to JavaScript for Sophisticated Programmers by Morgan McGuire), but it has its benefits: lighting-fast iteration times, lots of open-source third-party libraries, some nice language features such as functions as first-class objects and JSON serialization, and some decent tools. Most people will be more productive in JavaScript than in C++ once up to speed.

JavaScript is not as fast as C++, which is a concern when we are comparing a CPU-bound algorithm to previous work in C++. However, for GPU-bound work, JavaScript and C++ are very similar.

Try it.

Check out the WebGL Report to see what extensions your browser supports. If it meets the needs for your next research project, give it a try!

Two and a Half Books

I’ve learnt of two new books in the past few weeks, worth mentioning as books to check out at SIGGRAPH (or using Amazon’s “Look Inside”, of course):

iPhone 3D Programming: Developing Graphical Applications with OpenGL ES, by Philip Rideout, O’Reilly Press. A better title might have been “Programming OpenGL ES on the iPhone”, as it focuses on OpenGL ES more than on the iPhone per se. Which is fine; there are already lots of iPhone programming books, and almost none that are focused more on OpenGL ES itself (the only other OpenGL ES 2.0 book I know of is this one). The book is C++ oriented, with some Objective C as needed for glue. From my brief skim, this looks like a well-illustrated, readable guide that hits many different effects: reflection maps, skinning, antialiasing, etc. That said, I haven’t yet had the opportunity to program on any mobile devices, so can’t give an expert review. When I do give it a try, this looks like the book I’ll read first.

Update: A draft of this book is free on the web, see it here. It looks to be essentially the same as the published work (but with some hand-drawn figures), and is nicer in some ways, as the pages allow color images (always good for a graphics book).

Light & Skin Interactions: Simulations for Computer Graphics Applications, by Gladimir V. G. Baranoski and Aravind Krishnaswamy, Morgan-Kaufmann Press. This one’s out of my league as a casual skim. Paging through and seeing “the eumelanin absorption coefficient is given by…” and “Scattering in either the stratum corneum or epidermis…” shows me how little I know of the world in general. Anyway, interesting to see a whole book about this critical type of material. Searching through it, there’s minimal coverage of, for example, d’Eon and Luebke’s work, so I can’t say it has much direct application to interactive computer graphics at this point.

That’s all for the real books…

The half a book (at best): Game GPU Graphics Gems: Real-Time Rendering The Redux (aka GGGG:RTRTR), by anyone who wants to edit it. When I “edited” the quasi-book Another Introduction to Ray Tracing a few months ago, I thought back then that I’d start another book for SIGGRAPH. Like the first stunning collection, this was an hour of work gathering Wikipedia articles (hardest part was choosing a cover). There are plenty more articles to gather about interactive rendering, and you’re most welcome to add any good ones you find to this book, make your own, etc. – it’s a wiki page, after all. More seriously, I like having a single, tight page of links to Wikipedia articles about interactive rendering, vs. wandering around and haphazardly seeing what’s there.