🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Blended and nonblended objects.

Started by
11 comments, last by Castor3d 24 years ago
I think it it possible in OpenGL to write to the Z-buffer, but not test it. If you do this, and just draw the floor last with the test on, it must be fixed.
There''s a next problem:
- Say there''s a pixel behind the floor and a pixel in front of the floor.
- They both are rendered with blending and with a bright pixel as result.
- The Z-buffer holds the front pixel''s value, and after drawing the floor a bright pixel overlaps the floor.
- You want half bright pixel.

Few solutions :
- do your own Z-sort or Z-checking (very slow, but maybe not in your case, if floor aligned with axis...)
- Draw your floor as normal with Z-buffer. Change OpenGL state to "Check Z-buffer, but don''t change", and draw the stars.

So from all this comes another question:
Is there an OpenGL function to change to "Check Z-buffer, but don''t change" state (if there is such a state?)

Advertisement
OK, I think there''s a way (it worked for me):

1- depth buffer & blending must be on
2- then...

- draw floor (i.e. non blended polygons)
- disable depth buffer writing with "glDepthMask(0);"
- draw blended stars / particles / whatever
- enable depth buffer writing with "glDepthMask(1);"

and that''s all... it should work. Try it and tell us how it worked for you.

Toni
Toni
Oh my god!! That''s what i''ve been trying to find out for a week now! Thank you so much Toni, I am forever in your debt!!!

This topic is closed to new replies.

Advertisement