Jump to content
  • Advertisement
Sign in to follow this  
IceFront

OpenGL triangle shading with blending

This topic is 4827 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 never noticed this until now: I execute the follwoing simple code: glShadeModel(GL_SMOOTH); glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); glBegin(GL_TRAINGLES); glColor3f(1, 1, 1); glVertex3f(0, 0, -20); glColor3f(0, 0, 0); glVertex3f(-20, 20, -20); glVertex3f(-20, -20, -20); glEnd(); glDisable(GL_BLEND); The background is black so i expect to see a half transparent triangle with one fully bright vertex and a gradually blackening base. Indeed thats what happens, except: when i move my camera (always looking from (0, 0, 0) to various directions) the triangles colors shimmer. It remains stable for some rotation angles, once i cross a certain angle parts of it( heres the strange thing: not the whole triangle but parts of it) darkens, other parts brightens. The base line always remains black, as far as i can see, as it should, but the rest of it just doing whatever it wants. Since the background is black, the same picture should be drawn without the glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); I tried it, and it does draws the same traingle but also with the same strange effect i just described. I cant tell if its a bug in my program or just the way openGL should be? I forgot to mention that nothing else is enabled: no light, no depth testing, no textures, nothing.

Share this post


Link to post
Share on other sites
Advertisement
Have you got perspective correction turned on? (glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST))

Since otherwise the colour interpolation will not be perspective correct and may result in similar artifacts.

Share this post


Link to post
Share on other sites
tried it, no effect.
I use the gluPerspective function:
gluPerspective(50, (double)width / height, 0.1, 500)

Share this post


Link to post
Share on other sites
Ok, i made two screenshots, and although it is hard
to see the effect in still pictures, i did my best to
point out the artifacts.

http://img280.imageshack.us/my.php?image=before5ii.png
http://img280.imageshack.us/my.php?image=after2tb.png

Share this post


Link to post
Share on other sites
okay the blend lines give away why exactly it's occouring
It's a kind of polygon optimisation

It's splitting the tri up into tris that fit exactly into the screen

Because of the way it's being split, it's messing with the blending;
& you're seeing those faintly visible blend lines (nicely spotted)

Free Image Hosting at www.ImageShack.usFree Image Hosting at www.ImageShack.us

Free Image Hosting at www.ImageShack.usFree Image Hosting at www.ImageShack.us

This occours normally & is usually quite unnoticeable. But in your case it's being split differently in both of those 2 pictures
Something to do with the rotation is effecting the relative vertex order so it's being split across different edges each time
It could be a driver issue, but I'm afraid I'm not totally sure..
I can tell you why it appears to be happening but not what to do about it :/
Well that kinda gets you halfway to finding a solution doesn't it ? :P

Share this post


Link to post
Share on other sites
So, your saying it might be my comp.....
i'll test on a freinds comp and let you know how it works out.
thanks for your help :)

Share this post


Link to post
Share on other sites
it is my comp.
I tested it on a computer with gforce 2 and it works fine.
I have mobile ATI radeon 7500, with the latest drivers.
Anyone else encountered this issue? or know how to solve it?

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!