Wednesday, January 14, 2015

OpenGL Lighting Demo

I was able to learn about OpenGL and how to write shaders. Lighting in games is an effect that I think everyone takes for granted. My application demonstrates basic aspects of lighting used in games.


It starts by rendering objects to the screen

Then adding basic diffuse lighting (the arrow is the light source)

I also included the ability to show the difference between the Fragment and Vertex Shader. The Vertex Shader runs for each point on the geometry that makes up the object on the screen.  The fragment shader is run for every pixel between those points and are displayed on the screen.  Lighting in the fragment shader is more intense, but looks much better.

The last lighting aspect I added was specularity.  The shiny effect surfaces get when they reflect some of the light into your eye.

The next examples show the difference between frag and vertex shaders

Vertex Shader
 Fragment Shader


Vertex Shader
 Fragment Shader


0 comments:

Post a Comment