Sign in to follow this  
Hypnotron

Stencil Buffer for rendering doors/windows through walls

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
[quote name='Hypnotron' timestamp='1318565091' post='4872406']
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
[/quote]
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
[quote]
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

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