Sign in to follow this  

Shading

This topic is 2630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ();

}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this