Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Blending filters


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 illuzion   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 September 2001 - 01:09 AM

Hi At the moment I''m writing a particle engine, and apart from one thing it works fine. Each particle is drawn to the screen using a triangle fan, with the center being brightly coloured with an alpha of 1 and the edges having an alpha of 0. I use glColor3f(), and the 1 and 0 values are hard-coded so I know they really are there. With depth-testing turned off, I can use either glBlendFunc(GL_SRC_ALPHA, GL_ONE) or glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA) and it will draw the way I want (I''ve only tested it against a black background, but it looks OK) - each particle a bright spark with the edges fading away. When there are a lot of them together it becomes white. Unfortunately, with depth-testing turned on, I can see the edges of each particle - the parts that are supposed to be completely transparent aren''t. It looks pretty bad. So what I need is depth-testing turned on so the particles look ok compared to everything around them, and depth-testing turned off so the particles blend together properly. Help! I''ve tried fiddling with glDepthFunc and glBlendFunc - not every combination, of course.. If I use glDepthFunc(GL_ALWAYS) then it looks ok again but I think that''s also equivalent to having depth testing turned off So can anyone tell me what I''m doing wrong or what functions etc I should use? Thanks - dave.

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 September 2001 - 10:28 AM

Enable depth testing, but disable depth buffer updates.


#3 illuzion   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 September 2001 - 10:55 PM

How do I do that? I didn''t know you could disable writing to the depth buffer... they will still need drawn properly compared to other objects though?

#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 24 September 2001 - 09:21 AM


> How do I do that?

Easy:


glEnable(GL_DEPTH_TEST); // Enable depth testing
glDepthFunc(GL_LESS); // type of depth testing

// ... render your opaque objects here ...

glDepthMask(GL_FALSE); // Disable depth buffer writes
// --- render translucent objects ...
glDepthMask(GL_TRUE); // Enable depth writes



> I didn''t know you could disable writing to the depth buffer... they will still need drawn properly compared to other objects though?

Sure, it''s a standard trick used to render transparent objects. They will be correctly depth buffered against the opaque ones (since the depth test is still active), but they won''t mess the zbuffer values anymore, since you made the zbuffer read-only.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS