Archived

This topic is now archived and is closed to further replies.

stencil buffer problem on GF4MX440

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

I''m using stencil buffer to draw sky gradient behind my landscape... In the beginning of each frame I call glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); Then I draw the terrain, writing 1''s to the stencil buffer, and finally the sky only allowing it to draw if (stencil & 1) is zero. Now, this works perfectly fine on my main computer with a radeon 9700 pro (like this)... But on my older box with a GF4MX440 card the stencil buffer isn''t being cleared for some reason. I get normal 8-bit stencil buffer when I look at it with glGet, and it''s being written to by the landscape and tested correctly by the sky. But when I move the camera the landscape will leave black areas on the screen where the sky won''t be drawn. Has anyone else experienced something like this? It''s like the glClear is having no effect on the stencil.

Share this post


Link to post
Share on other sites
I''ve found stencil to be finicky on some cards; whether you have 16- or 32-bit desktop; etc. If you want it to be consistent, you must ChangeDisplaySettings() to a 32-bit desktop BEFORE you create the context, and then ask for 24 bits Z, 8 bits stencil, 24 bits RGB and 8 bits alpha.

Do you use the Z buffer for your regular geometry? If so, you can draw the sky at the end, very far away, with Z testing on, and it''ll put the sky behind everything else. No stencil necessary.

Or you can draw the sky first of all, without any Z testing; this lets you avoid the framebuffer clear, and you can clear Z _after_ drawing the sky. No stencil necessary. This is what I do.

Share this post


Link to post
Share on other sites
1. Yes, I use glClearStencil(0); even though the default according to the spec is 0 anyway.

2. All the bits are set right. I''m running this in a window btw (Yes, my desktop is 32bit). I don''t really want to move the sky farther away as it would require increasing the far plane distance and possibly mess up rendering things that are outside the atmosphere. Also, I must use glClear because the camera can be outside the atmosphere (see the first pic).

I can draw the sky first without z-write but I was hoping to avoid this and save a bit of fillrate. Time to add another option flag I guess...

Share this post


Link to post
Share on other sites