21. Lighting - Types
• Ambient Light: doesn’t come from any particular direction. It has an original
source somewhere, but the rays of light have bounced around the room or scene
and become directionless.
22. Lighting - Types
• Diffuse Light: The diffuse part of an OpenGL light is the directional component
that appears to come from a particular direction and is reflected off a surface with
an intensity proportional to the angle at which the light rays strike the surface.
Thus, the object surface is brighter if the light is pointed directly at the surface
than if the light grazes the surface from a greater angle.
23. Lighting - Types
• Specular light: Like diffuse light, specular light is a highly directional property, but
it interacts more sharply with the surface and in a particular direction.
42. Shadowing
// Draw objects in the scene, including base plane
DrawModels(GL_TRUE);
// Enable alpha test so that shadowed fragments are discarded
glAlphaFunc(GL_GREATER, 0.9f);
glEnable(GL_ALPHA_TEST);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
// Set up shadow comparison
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,GL_COMPARE_R_TO_TEXTURE);
// Set up the eye plane for projecting the shadow map on the scene
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);
….
DrawModels(GL_TRUE);
73. Simple Particle System
• glTexCoord2d();
typedef struct // Create A Structure For Particle
{
bool active; // Active (Yes/No)
float life; // Particle Life
float fade; // Fade Speed
float r; // Red Value
float g; // Green Value
float b; // Blue Value
float x; // X Position
float y; // Y Position
float z; // Z Position
float xi; // X Direction
float yi; // Y Direction
float zi; // Z Direction
float xg; // X Gravity
float yg; // Y Gravity
float zg; // Z Gravity
} particles; // Particles
particles particle[MAX_PARTICLES]; // Particle Array (Room For Particle Info)