Lightning in OpenGL with Material Effect

This is second tutorial on Lightning in OpenGL. In this tutorial, I will discuss about producing Material Effect in OpenGL. Material parameters specify how a surface reflects light. Applications change OpenGL material parameters to emulate different colored materials, shiny and flat materials, high gloss materials such as pool ball, etc.
The routine glColor3f(), sets the primary color and is a good idea to call this routine as long as we are not using lighting effects. The OpenGL lighting doesn’t use the primary color, instead uses the material colors. Hence it is important to introduce materials while talking about lighting.

So far we have seen a simple lighting example which has no material effects. But, in order to make the scene more attractive, we have to make use of materials. In the following code, we have used a green material. We make use of GL_SPECULAR, GL_AMBIENT, GL_SHININESS depending on the
scene requirements. The same parameters are also applicable to lighting methods.

Source Code:

Output

Lightning in OpenGL with Material

SHARE Lightning in OpenGL with Material Effect

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Share