Jump to content
  • Advertisement
Sign in to follow this  
d000hg

Possible to fake simple boolean geometry operations using shaders?

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

In 3D modelling programs, you can have solid objects, rather than hollow polygon shells. You can cut them in two, or subtract a sphere, etc, and new surfaces are generated to fill the gaps. Is it possible to do this using a shader in real-time? I really would only need to do this with a plane - so imagine simply slicing a model and throwing one half away. It's easy to have a shader to only draw the pixels in the model on one side of the plane, but the tricky part is filling in the big gap. The idea in my head is to render the slicing plane first, and then render the rest of the model, somehow leaving the slice-plane only where it is needed. Can someone comment on this idea, is it viable? If so, any thoughts on a more detailed algorithm would be appreciated, since shaders are not my strongest area.

Share this post


Link to post
Share on other sites
Advertisement
Draw your object, discarding pixels that would be cut by the plane. Write to the stencil/alpha buffer where this occurs.

Draw the slicing plane, but only draw where the stencil/alpha buffer is set to the value you chose above.

Share this post


Link to post
Share on other sites
The technique you're after is image space CSG, there's a few papers on the internets that should be enough to get you started. This one seems to have some easy to follow (pseudo)code.

I'm pretty sure that you have to use manifold geometry for them to work, so you'd have to render a large enough box instead of a plane.

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!