Jump to content
  • Advertisement

Archived

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

Blending + Z-Buffer = Bad

This topic is 6151 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 I should probably have posted this in OpenGL forum but i''ve noticed not many people post there so forgive me... Anyway here is my problem: as I implemented my particle system i realized a defect which occurs when two particles are rendered in front to back order (since I''m not ordering my particles back to front). The problem is, let''s say if I have a smoke puff and an explosion behind it, if i render the smoke puff first and then the explosion, although the smoke is translucent, i can''t see any of the explosion. The obvious choice is to disable Depth test (Z-buffer) which is what the tutorial i''ve seen do, but that''s not a good solution because I don''t want to see particles through the terrain. There remains 2 solutions, either i can order all particles across all systems in a back to front fashion (which can be slow and might not work for some systems that have a different rendering functions) or, after rendering the terrain, somehow make OpenGL to check the Z-Buffer at each pixel but NOT write the new Z value to that pixel. That means the particles will get clipped by the terrain, but not by other particles. Is this possible with OpenGL (or DirectX for that matter)? Is there any other ways around this problem. If I have to order things from back to front can you suggest an efficient method Thanks in Advance

Share this post


Link to post
Share on other sites
Advertisement
Hi again

I wanna sincerely apologise for this. I hate it when ppl ask a question and then answer themselves 2 minutes later but looks like i''ve done it too.

Anyway for those who might have the same problem, the function i was looking for is glDepthMask. glDepthMask(0) disables writing too z-buffer and glDepthMask(1) enables it. This is EXACTLY what i needed.

Again sorry about that

Share this post


Link to post
Share on other sites
You shouldn''t hate people asking a question and answering it themselves 2 minutes later. This is actually something that is encouraged in programming

Alot of times simply taking the time to pose the question to others gives you a different perspective on the problem.

Seeya
Krippy

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!