Jump to content
  • Advertisement
Sign in to follow this  
Blasteroids

OpenGL Alpha blendied objects produce "popping"

This topic is 4113 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 have made a little graphics engine in opengl, using a scenegraph approach. Currently I am generating 100 cubes offset from a given location. Each cube has its own size and colour, about 50% have alpha for transparency. The renderable objects, after frustum culling, are pushed into a rendering buffer. The rendering buffer sorts the objects into alpha and non-alpha lists. It orders the non-alpha objects from front to back. It orders the alpha objects from back to front. I then render like so; Depth Test is always enabled. For Non Alpha objects, DepthWrite is enabled. Blending is disabled. Objects are then rendered. For Alpha objects DepthWrite is disabled. Blending is enabled. Objects are then rendered. Now when I rotate the inital location that the cubes are offset from, I get "popping" from the alpha cubes when their location ( taken from middle of cube ) changes. I.e. cube1 with alpha comes closer than cube2 with alpha, so in essence the draw order changes. Does anyone know of a solution to this? Also, a little strange question. I am keeping account of opengl state changes to reduce the amount of times they change. I noticed that GL_DEPTH_TEST seems to reset to a disabled state, could not turn it on again because my state variable said it was already on! Anyone know of a reason why OpenGL would turn off GL_DEPTH_TEST ? Also, is there a way to ask OpenGL the current state of GL_DEPTH_TEST? I could then try and track exactly where it changes. Many thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
u could use depth peeling (google)
i assume youre doing the sorting on a per object (cube) perhaps try per polygon (though this is still not gonna solve it always)
--------
u could use the program glintercept or gldebugger
to see what the current state is look at the back of the gl space they have a large table of how to query stuff (in this case itll prolly be glIsEnable( GL_DEPTH_TEST ); or glGetIntergerv( GL_DEPTHTEST ) or something similar)

Share this post


Link to post
Share on other sites
Quote:
Original post by Blasteroids
I have made a little graphics engine in opengl, using a scenegraph approach.
Currently I am generating 100 cubes offset from a given location.
Each cube has its own size and colour, about 50% have alpha for transparency.
The renderable objects, after frustum culling, are pushed into a rendering buffer.
The rendering buffer sorts the objects into alpha and non-alpha lists.
It orders the non-alpha objects from front to back.
It orders the alpha objects from back to front.

I then render like so;
Depth Test is always enabled.

For Non Alpha objects,
DepthWrite is enabled.
Blending is disabled.
Objects are then rendered.

For Alpha objects
DepthWrite is disabled.
Blending is enabled.
Objects are then rendered.

Now when I rotate the inital location that the cubes are offset from, I get "popping" from the alpha cubes when their location ( taken from middle of cube ) changes. I.e. cube1 with alpha comes closer than cube2 with alpha, so in essence the draw order changes.

Does anyone know of a solution to this?

Also, a little strange question. I am keeping account of opengl state changes to reduce the amount of times they change. I noticed that GL_DEPTH_TEST seems to reset to a disabled state, could not turn it on again because my state variable said it was already on! Anyone know of a reason why OpenGL would turn off GL_DEPTH_TEST ? Also, is there a way to ask OpenGL the current state of GL_DEPTH_TEST? I could then try and track exactly where it changes.

Many thanks in advance.



glIsEnabled(GL_DEPTH_TEST);


http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/isenabled.html

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.

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

Sign me up!