…and then I said, let there be light! …and there was light!
So after having studied OpenGL shaders a bit in my book, I’ve made another textured cube: this time the texture is a wooden box instead of the OpenGL logo. Also I’ve added lighting using vertex and fragment shaders.
Basically how it works is, there’s a diffuse light source in the scene at -100.0, 100.0, 100.0 and some ambient lighting too ( 30% ambient contribution ). The vertex shader interpolates the texture coordinates, and the diffuse lighting between the vertices for the fragment shader, and then the fragment shader samples the texture at the interpolated coordinates and multiplies the color with ( ambient + diffuse ).
Fairly simple, and yet looks pretty nice imho. So enjoy!