Sign in to follow this  


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;
glutSolidSphere (0.2, 20, 16);
glTranslatef (0.0, 0.70, 0.0);
glutSolidSphere (0.5, 20, 16);
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:
For shadow mapping:

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

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