Book Review: A Tale of Two WebGL Books
I made it through Professional WebGL Programming: Developing 3D Graphics for the Web over the past weekend and picked up and read through WebGL: Up and Running this week.
As WebGL books go, these two constitute 2/3rds of what’s currently available on the market for WebGL books. The remaining title is WebGL Beginner’s Guide, which I haven’t had a chance to read (and truthfully, at this point, I’m not sure I’m going to make it through another WebGL book anytime soon) From the table of contents, WebGL Beginner’s Guide actually looks comparable to Professional WebGL in terms of material (it focuses on straight WebGL), so it might be worth a look.
I have mixed feeling about Professional WebGL Programming: Developing 3D Graphics for the Web. On one hand it covers all the material I expected it to cover, and covers it pretty authoritatively. On the other hand, the writing style is sometimes hard to follow and it’s often difficult to see the forest through the trees of the technical detail. And I say this as someone who has done OpenGL programming in the past (in the pre-shader days, however) and is familiar with 3D programming in general.
The author clearly has deep knowledge of 3D and WebGL, but the first question a WebGL book must face is: how is it better than the Learning WebGL intro lessons? The answer is that the Learning WebGL intro lessons, while pragmatically useful, focus more on getting things up on the screen than giving you an exhaustive accounting of the API. The latter is what this book does, and that’s both good and bad.
If I we’re new to 3D programming I think I would find myself pretty overwhelmed with technical details instead of understanding the utility of each of the pieces of the API. One example of this is Blending, which doesn’t show up until the end of the book, strangely under WebGL performance optimizations. The section goes on for five pages before explaining what you might commonly use blending for (transparent objects) and the caveats to rendering those objects in the correct order. The book is laser focused on the WebGL API and doesn’t cover thing like model loading, walking around a scene, etc. If you’re new to 3D, there’s still going to be a big gap from finishing this book to building 3D games.
On the other hand, if you’ve got some experience in 3D, Professional WebGL is pretty spot on. It covers the WebGL API fairly exhaustively, spends a good amount of time on shaders and provides and explains in depth the shader code for all the standard transformations, texturing, light reflection models and lighting models. At 361 pages, it actually qualifies as short for the amount of material it covers
For the most part, Up and Running isn’t about the WebGL API at all, but rather it’s about how to get you writing cool 3D stuff in the browser as quickly as possible. If you’ve ever done any OpenGL programming, you know that it’s a very low-level API, and getting even basic shapes onto the canvas is a chore (a simple triangle is 150+ lines) Up and Running takes a different approach and uses the hyper-popular Three.js library for the majority of the book.
Using Three.js means that the majority of the book works at a much higher level than straight WebGL (The author even creates Sim.js, an abstraction on top of Three.js to keep code duplication down).
Because the code is at a higher level, in 230 action-packed pages the author has time to cover hit detection, picking, and exporting, loading and animating 3D models. The book culminates in a simple 3D racing game that ties it all together. All that stuff Professional WebGL didn’t have space to cover because it was dealing with the nitty-gritty of actual WebGL.
This high-level code comes at the trade-off that you’ll walk away from the book with barely any experience in the actual WebGL API itself. Is this a problem? Depends on your goals. Three.js is massively popular and has been used in the vast majority of cool WebGL stuff you see on the Web (including full-blown games like Trigger Rally) It also is lacking documentation, so a book that covers it in depth is sorely needed, and that’s exactly what Up and Running provides.
Bottom Line: If you want to get started building cool 3D stuff in the browser or have had trouble getting started with Three.js, this is 100% the book for you. If you’re a 3D vet and are looking for details on the WebGL API itself, Professional WebGL may be more your cup of tea.