Jump to content
  • Advertisement
Sign in to follow this  
giugio

depth buffer cull

This topic is 2995 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.
I would renderize a little sphere(sphere 1) in a scene with a vertex shader and a pixel shader.
Next I would create in the z-buffer a filled sphere(sphere 2)more big , and i would test each pixel in my little sphere (sphere 1)is inside of the sphere 2.
IS possible?
If yes , how?
thanks

Share this post


Link to post
Share on other sites
Advertisement
If I understand this correctly you want to write all the pixels from Sphere 1 that intersect with Sphere 2?


If this is the case I would use a stencil buffer. I assume the near to far plane difference between S1 and S2 doesn't matter.

1. Create a depth buffer that has stencil buffer
2. Bind the depth buffer
3. Disable writing to depth buffer
4. Enable writing to stencil buffer (using 0xFF, or anything that is higher than 0)
5. Render Sphere 2 (the bigger one)
6. Bind the render target (with the previously created depth buffer)
7. Enable writing to depth buffer
8. Disable writing to stencil buffer
9. Setup the render state so that stencil buffer value must be equal to the value you wrote to the stencil buffer.
10. Render Sphere 1
11. ...

You can do further reading on this subject by googling: Stencil Buffer Techniques (Direct3D 9).

Regards,

Xeile

Share this post


Link to post
Share on other sites
thanks.
The pseudocode is ok , is correct also for dx 10 or 11 ?
1)There is an example or a tutorial on that in the documentation of dx?
2)Is an heavy operation or is relatively fast?

thanks.

Share this post


Link to post
Share on other sites
The technique is uniformal over DX10, DX11 and even OpenGL, the API call names may be vary though.

1) I don't know any particular tutorials, but using the stencil buffer isn't all that different from using the depth buffer. Perhaps this helps you on your way: Stencil Buffer Techniques (Direct3D 9)
2) The steps I mentioned in my pseudocode are fast. Drawing your Sphere 2 is faster than drawing Sphere 1, since 2 doesn't use an expensive pixel shader.

Share this post


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