Jump to content
  • Advertisement
Sign in to follow this  
dnaxx

Stencil buffer and depth

This topic is 4556 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

hello! I am using the stencil buffer for shadows. It works, but shadows that are occluded by another object, are drawn through this object. I am using this code for the shadows:
	glDisable(GL_LIGHTING);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_TEXTURE_2D);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glEnable(GL_STENCIL_TEST);
	glStencilFunc(GL_GREATER, 1, ~0);
	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

	glColor4f(0,0,0,0.5);
	
	// - transform matrix to shadow mode
	// - draw shadow casting object (==shadow)
	// disable blending, reset other options from above and continue to draw scene

And here is a sample of the "shadow problem" (the shadow casting object is behind the mountain but it's shadow shines through): One solution would be to do something like occulision culling, but I would prefer an easier solution ;). thank you,

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!