Jump to content
  • Advertisement
Sign in to follow this  
rgibson11

OpenGL Triangle overlap + transparency

This topic is 2755 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 am trying to solve an annoying problem with my transparency
I only need to have the main character fade out so I used glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Which works great to blend my character with the background over a period of 5 seconds
but you can clearly see individual triangles inside the characters back causing weird artifacts
I am guessing this is due to the fact that triangle order is messed up.

I am a bit confused at what I could try to do to solve this.

Order indpependant transparency? seems a bit too much to implement for a single transparent object

triangle sorting in shader somehow? I dont have access to triangles outside of shader due to the fact I am using a library that handles animation

Some unknown opengl setting that could fix it?

Orthographic projection?

Screw it and just delete the entire fading out code?

Anyone know what to do?

Share this post


Link to post
Share on other sites
Advertisement
Do you have backface culling turned on? If not, that should eliminate most of the tris you are seeing thru the model. Otherwise you would need to sort the tri's from front to back and you mentioned you don't have access to these. Sorting would be really expensive anyway...

Share this post


Link to post
Share on other sites
Render the character to a completely different texture by itself, apply that texture (on a quad) over the scene (don't render the character to the scene). You can then fade that single quad out without any sorting or messing with the character itself. So:

Render scene as normal (without the character)
Render character by themselves at full opacity to some render target (of screen texture).
Render that texture on a quad over the scene with the desired transparency.

Share this post


Link to post
Share on other sites
Nanoha's method would work. Another way is you could draw the character once with a 0 alpha (you just want to write depth values), then draw the character again over top of that with GL_EQUAL as your depth test, this way you dont have to sort triangles as the 2nd drawing has to match the first one (only triangles you see anyway). Never tried it though.

Share this post


Link to post
Share on other sites
You can also do a two passes rendering. First you render the environment without your character, then only the character with backface culling as BuffaloJ has suggested.

Share this post


Link to post
Share on other sites
I don't recommend ever using glEnable (GL_LINE_SMOOTH), glEnable (GL_POLYGON_SMOOTH) and glEnable (GL_POINT_SMOOTH), if you are using them.
http://www.opengl.org/wiki/Common_Mistakes#GL_POINTS_and_GL_LINES

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!