Tuesday, July 2, 2013

Stumbling back into the third dimension


There's not much to look at here, but what you're looking at is a variation on the Learning WebGL, Lesson 1 sample, which is, itself, a variation on the NeHe OpenGL Lesson 2 tutorial. So, we're back to square one. And triangle one. Yay.

I've done a fair bit with OpenGL over time, but I've never got the hang of using shaders. Well, it looks like WebGL is all about shaders. Whee.

A couple of things I've tinkered with, above:

  • Colors - not that interesting. The background color is just a different argument to the gl.clearColor call. The red polygons involve changing the value returned by the uniform fragment shader. Actually, I created a red uniform fragment shader, in addition to the white one that the lesson provided, and then plugged that fragment shader in. I'd have colored the two polygons different, but I don't know how to do that, yet.
  • Angles - vaguely interesting. Lesson 1 positions the polygons relative to the camera, rather than relative to the world, which is a little gross, but I can see what they're doing, I can see what I'd have to do to make it less gross (hint: a matrix for where the model is relative to the world, and a matrix for where the camera is relative to the world). In the lesson, they use translations (no rotations) to put the polygons in interesting places onscreen. What I've gone and done is use mat4.lookAt to move the camera to a more interesting position to look at each of the polygons, giving us a little more interesting view. Not very interesting, I'll agree, but a little more suggestive that we're using a 3D system that can handle perspective, if that's what we want.
A few things that I feel I ought to do next, before progressing to the next tutorial:
  • Update glmatrix. This sample is using glMatrix 0.9.5, which I'm sure was fine in its own way, but the current documentation for glMatrix is 2.2.0, so... yeah. There are improvements that I'd like to use, as well as being able to know where my arguments belong.
  • Refactor. Maybe I can put stuff into my game framework earlier rather than later this month.
And then, a few things I want to learn in later tutorials would include:
  • Multiple Materials. Red is fine, really. But I will want to do more than that.
  • Texture Maps. Maybe. Well, especially if I want to do screen stuff. Probably.
  • Lighting. This doesn't have to be fancy, just a flat shaded dot product to the light source kind of thing would be fine, just something to make my cubes that I intend to draw not look like a flat hexagon.


No comments:

Post a Comment