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.

No comments: