teaching machines

Feature 3 – Light Your Scene

March 17, 2013 by . Filed under cs455, postmortems, spring 2013.

This should be a pretty short post, because lighting is something that we have been doing for a while now.  To light my scene, I am currently using a combination of diffuse, ambient, and specular lighting, depending on which objecting I am applying the light to.  I still have pretty generic albedos for my objects, but that’s not really the point of this post, and it should be clear that I have the lighting working from the screenshots and the video that I have posted.

I didn’t run into any programming challenges while doing this, since I was simply able to reuse the shaders that we had been working on for a while now.  However, I did have an issue with the plane object that I found on the Internet having normals that faced the wrong direction, causing large dark spots to appear when the plane was fully lit.  Dr. Johnson helped me solve this by showing me that you can recalculate the normals in Blender before exporting an obj file.  Occasionally, the glDepthTest function would also cause some glitchy behavior when I had the light position orbiting around the x or z axis, because for some reason, when the light was under the landscape, some of the leaves would still light up.  I decided that this would be something that I would work on later, when I have a bit more time to think.  For now, since my skybox is going to be a daylight scene, I would simply leave the light position above the landscape at all times, casting my landscape into perpetual daylight.

Finally, I was encouraged to cull the back faces of my geometry, which seems like a topic that might fit best with this post.  I tried it, but eventually decided against this.  I realize that it optimizes the program, but most of the plant objects that I found were single-sided, and if you were to cull the back faces, you would cull at least half of the leaves on a tree/bush.  For now, I am going to avoid culling… at least until I find some better geometry.

Here is the fragment shader that I used for specular lighting.

Here are some screenshots of different objects in my scene that I have lit.

 

Here is a link to the video I posted: