• Advertisement
Sign in to follow this  

Blending settings question

This topic is 861 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 everybody,

 

As you can see in the picture, I'm rendering a serie of cylinder which are dynamically moving. It's to show a sort of 3d path.

Anyway, I want them transparent like how they are right now but as you can see where they overlap of course there is an artifact I'd like to get rid of.

I'm using the usual settings: source = source_alpha and destination = one_minus_source_alpha.

 

Is there any state settings or any way to have the same transparency everywhere for those overlapping cylinder ? So where they intersect the alpha is not taking any other cylinder into account.

 

Cheers !

 

Share this post


Link to post
Share on other sites
Advertisement

You could use the stencil buffer to only draw where you havn't already drawn. Look up stencil buffer.

Share this post


Link to post
Share on other sites

Thank you all for your answers. As I don't have access yet to the stencil buffer with our proprietary api, I'll try swiftCoder method which seems great to me.

Share this post


Link to post
Share on other sites

You can render the cylinders with depth write on and glColorMask off (or the DIrectX equivalent) so that you don't write any pixels, this 'primes' the depth buffer. Then, render the cylinders again with depth test set to equal, and whatever blending you like.

Share this post


Link to post
Share on other sites

Well, after some tests, I want to avoid C0lumbo method just to render the cylinders only once.

I cannot use the stencil buffer as I don't have the interface to use it.

 

So I tried swiftCoder method which seems great at first but it won't do what I want. My depth test is enable and I'm writing to it. The cylinders are z sorted and rendered front first and I have the blending enable. So I can see the scene through them but I cannot see other cylinders through them which is what I want, fine.

 

But the problem remains where they intersect in fact. And this is normal as the z being written is indeed behind at some point no matter which cylinder is being drawn first.

So I guess this leaves me to ask for the support of the stencil solution...

Or maybe ask for the support of glDepthFunc and set it to GL_NEVER...

Share this post


Link to post
Share on other sites


But the problem remains where they intersect in fact. And this is normal as the z being written is indeed behind at some point no matter which cylinder is being drawn first.

Yeah, I wasn't thinking that all the way through. Your cylinders are mutually overlapping at some corners.

 

Obvious alternatives:

  • Render opaque cylinders to an offscreen buffer, and then blend the whole buffer into the main scene on a fullscreen-quad.
  • Stop using cylinders, and render a quad-strip (or 'billboard trail') instead.

Share this post


Link to post
Share on other sites

Is it unacceptable to dynamically generate the cylinder geometry such that they're not instersecting like that?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement