Showing posts with label opengl. Show all posts
Showing posts with label opengl. Show all posts

Wednesday, September 02, 2009

OpenGL: Diffuse, Specular, Ambient, Emissive lights

In the OpenGL world there are different types of light types

Diffuse
--------
These type come from one direction bu are scattered equally in all directions.

Specular
--------
This type of light comes in one directions and is also bounced off in one direction

Ambient
--------
This type of light source comes from different light sources and is also scattered in different directions

Emissive
---------
This represents light originating from the object

So in general A light source has two types of properties associated with it
LR,LG,LB => the RGB components that make up the light and
MR,MG,MB => the RGB components that are reflected away
Hence the net effect of the RGB is given by a vector

(LR.MR, LG.MG, LB.MB)

if light is coming from two or more sources the light is added and next effect is
of the form

(R1 + R2, G1 + G2, B1 + B2)

Tuesday, September 01, 2009

Opengl : Hidden Surface Removal and LIghting

Hidden surface removal is a common technique in the graphics world. The technique says
we should draw only parts of objects that are visible to the user.

What support does OpenGL have for hidden surface removal.OpenGL supports hidden surface removal through a combination of DEPTH BUFFER and COLOR BUFFER.

Depth Buffer and Color Buffer
------------------------------
Our screen is flat basically we see a flat 2D rectangular screen made up of pixels. Associated with these pixels we have a corresponding value in the Depth Buffer and
Color Buffer. So what pixel appears forward or backward depends on its value in the depth buffer. The color value it shows depends on its value in the color buffer.

to enable the depth buffer we need use something like the following:

glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);

Material And Ambient Light
---------------------------
OpenGL understands RGB. A material quality decides the amount of RGB that is reflected or absorbed. An area can be lit by many light sources.Say in a room the bulb can the primary source of light.But there might be light reflected from walls which can be called secondory sources, the light contributed by such sources is called ambient light.