Shading

Started by
0 comments, last by Erik Rufelt 13 years, 6 months ago
Hy pals. Ok, I thought that I had learnt the basics about how to set my sources of light and so on. But unfortunately I have noticed that the objects in my scenario do not make shade each other. In the code below, the upper sphere does not shades the second sphere just below of it. What should I do inorder to get such effect?

Thanks in advance.

void display(void)
{ int i,j,f,k=0;
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (0.2, 20, 16);
glPushMatrix();
glTranslatef (0.0, 0.70, 0.0);
glutSolidSphere (0.5, 20, 16);
glPopMatrix();
glFlush ();

}
Advertisement
This requires a shadowing technique, for example shadow mapping or stencil shadows. Older games faked this by drawing a polygon that looks like a shadow under the object or similar, and newer games do it with GLSL shaders.

If you want the true effect without shaders, the following tutorials seem to do it.
For stencil shadows: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=27.
For shadow mapping: http://www.paulsprojects.net/tutorials/smt/smt.html.

I found these with Google, and searching for stencil shadows or shadowmapping tutorials will give you several hits. I would recommend learning GLSL shaders first however, as it will make it easier and more efficient to implement such techniques.

This topic is closed to new replies.

Advertisement