What madness possessed me that day I
will never be able to explain. Having accomplished what needed to be done, why
did I press on? I do not know myself what unconscious self-destructive character flaw caused me to innocently go
forward and attempt to learn the forbidden knowledge that lurks just below the surface of WebGL.
Those who watch, those who control, those who oppress our pathetic lives through means both grand and small, yes even through those apparently innocent graphics API committees that design our APIs.
Those who watch, those who control, those who oppress our pathetic lives through means both grand and small, yes even through those apparently innocent graphics API committees that design our APIs.
Or put another way, I decided to move forward and add texture mapping and multiple objects to my little WebGL object viewer which is really just an excuse for learning WebGL.
1. I attempted to use the feature,
attribute arrays, to download the UV coordinates for use by the
shader. But even though I have used this feature successfully for
the vertices, colors and normals I could not make it work for UVs.
2. Texture mapping would not work. After a while I figure out that
my texture map is not an exact power of two, and that seems to be
fatal. First, I do not think that is clear in the documentation.
Second, why is the only error code that WebGL seems to know about is
"error"? Why can there not be more informative error
messages?
3. I use a trick to get the UV
coordinates to the shader, and that works, but I can not use that
trick in the final software.
Yeah ! A cube with a texture map !
4. In the process of writing slightly
more sophisticated shaders, I discover that (a) functions are tricky and that (b) it is not clear which GLSL (shader language)
WebGL implements unless you read very carefully (the answer is that it implements GLSL ES 1.0 only) and (c) there is no obvious documentation. There is documentation it turns out, but you have to go searching around for the documentation for OpenGL ES 2.0's 1.0 shader language. Confused? You should be, there are many, many OpenGL shader languages defined out there and they are all different yet similar.
5. In the process of doing this, using
textures and so forth, Firefox on Windows gets a hard failure
because I am not using vertex attribute 0. Really, why does it care?
6. Once I start using texture maps,
Google Chrome, which had been very compatible before, now fails hard
with the following security error.
Security violation? What security violation? I am loading a texture map, ok?
Here are the conclusions I drew from
this not very fun 72 hours:
1. WebGL is fragile. You may
think you have learned how to do something in WebGL, but its
possible that you did not and that you got lucky. You may not be
able to use that feature in the future, or you might, but you do not
know.
2. WebGL is designed to a very low
level. Even the API for the 2D canvas is at a much higher level
(and much more usable) than the 3D API. The only solution seems to be to write your own management system to do basic stuff that could or should have been done for you.
3. The WebGL error system is nearly useless.
It does not give enough information to diagnose problems and errors.
4. The WebGL documentation is problematic. There is no reference manual, there is no shader language
documentation (it turns out there is, but you have to be a detective to figure out which one it is and where it is), there is way too much reliance on group sourced internet
tutorials that are very low level and often incorrect or unhelpful.
5. It is not clear how much a problem
browser compatibility is. Initially there did not seem to be any
problem but as of yesterday I am dead in the water and I can not
figure out what it is complaining about. Therefore be warned,
browser compatibility is a real issue.
6. This might all just be a problem of software (im)-maturity. Maybe it will all get better with time. Maybe someone will write a Javascript package to smooth over the loose ends and everyone will use that API instead of the WebGL one.
7. One does what one always does in this situation. You write your own software to hide the ugliness of the underlying system and after a while the problems go away. The irony here is that OpenGL was originally created to make it easier for people to start doing 3D. It has evolved into something that seems to take pride in making it as difficult as possible for a beginner to do 3D. Weird.
6. This might all just be a problem of software (im)-maturity. Maybe it will all get better with time. Maybe someone will write a Javascript package to smooth over the loose ends and everyone will use that API instead of the WebGL one.
7. One does what one always does in this situation. You write your own software to hide the ugliness of the underlying system and after a while the problems go away. The irony here is that OpenGL was originally created to make it easier for people to start doing 3D. It has evolved into something that seems to take pride in making it as difficult as possible for a beginner to do 3D. Weird.
There are a lot of positive things to
say about WebGL (including the ability to run a 3D application from a
browser which means that the end-user does not have to install a
program). But if I were advising a client on whether or not to
commit to doing an application that was important to the company
using WebGL, I would tell them "Maybe, but proceed with caution". This is a very
low-level API, it is not yet robust or documented. One will need to do tests and carefully evaluate whether what you need to do can in fact be done in this environment and at what cost. Look before you leap.
No comments:
Post a Comment