Jump to content
  • Advertisement
Sign in to follow this  
Hypnotron

Stencil Buffer for rendering doors/windows through walls

This topic is 2560 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,

Currently I'm using the stencil buffer to render holes through arbitrary visible geometry using non visible geometry that serves as the "punch.".

Right now I'm rendering all the stencil geometry at once, then switching and rendering all the targets at once and this results in targets being invisible _IF_ they are looked at through another hole.

Is the only way to fix this to alternate rendering between the associated pairs of source stencil geometry and target geometry? I'd like to avoid the alternating of state changes if possible. Plus my current implementation I dont have to actually maintain references between the specific source stencil geometry and it's target. If i have to alternate then I will have to implement this sort of tracking.

Thanks in advance!

-Mike

Share this post


Link to post
Share on other sites
Advertisement

Hello,

Currently I'm using the stencil buffer to render holes through arbitrary visible geometry using non visible geometry that serves as the "punch.".

Right now I'm rendering all the stencil geometry at once, then switching and rendering all the targets at once and this results in targets being invisible _IF_ they are looked at through another hole.

Is the only way to fix this to alternate rendering between the associated pairs of source stencil geometry and target geometry? I'd like to avoid the alternating of state changes if possible. Plus my current implementation I dont have to actually maintain references between the specific source stencil geometry and it's target. If i have to alternate then I will have to implement this sort of tracking.

Thanks in advance!

-Mike

I've no solution to the stencil issue, but when your "hole" geormetry is quite simple (cylinder,sphere,elipsoid) then I would try to use alpha masking/discarding the pixel in a shader. This way you could render everything in a single pass, but this will only work, if you have very few of this hole-objects per rendered object. L4D2 uses such an approach to render the wounds of zombies.

Share this post


Link to post
Share on other sites

I've no solution to the stencil issue, but when your "hole" geormetry is quite simple (cylinder,sphere,elipsoid) then I would try to use alpha masking/discarding the pixel in a shader. This way you could render everything in a single pass, but this will only work, if you have very few of this hole-objects per rendered object. L4D2 uses such an approach to render the wounds of zombies.
[/quote]



Thanks. I will give this some thought. I spent a few extra hours last night trying to see if there were some stencil pass renderstates I could tweak to get it working without rendering source & targets in pairs and I also tried rendering targets back to front, but neither with success.

-Mike

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!