tags:

views:

76

answers:

2

I'm drawing lots of semi transparent polygons. My scene is 2D and uses 2f verticies. I can't use the depth buffer since it wont help because of alpha blending. What are some other techniques to reduce overdraw since this is what is crippling my application, not polygon counts since I use VBO's. Thanks

+3  A: 

First off, how have you determined that overdraw is your problem? Without more information about what exactly you are drawing, it is quite hard to guess how to draw it faster. Speaking generally, the key to avoiding over draw is to avoid drawing anything that isn't required. So, if you have a 2D side scroller game with several layers of background image scrolling independently for parallax purposes -- sky, clouds, mountains, forest far, and forest near -- you would want to avoid drawing the sky wherever any of the other layers is visible. So, if you know that the mountains are guaranteed to cover a certain part of the sky, change the shape of your sky poly to only draw in the areas where you expect the sky to be visible. Potentially, make a fairly high resolution grid for the sky which follows the shape of the mountains, if you still have a problem. Likewise, if the ground plane of the forest layers is guaranteed to cover a certain height span, then don't have the mountains being drawn in that area.

OTOH, on modern video hardware, a few layers of overdraw in a 2D scene is usually not that big of a deal, so I'm still interested to know exactly how you determined this, and if there might be some sort of bias in your instrumentation and profiling which could be leading you astray.

wrosecrans
+1: My thoughts exactly :)
Jon Cage
I'm making a vector drawing application, I'm pushing it and after about 35 layers it gets laggy, not on my pc, but on my laptop, I just wanna make it as fast as possible.
Milo
want me to upload the exe so you can evaluate yourself?
Milo
@user146780: Sure, it could help!
Stringer Bell
A: 

In your specific scenario, I would consider rendering some batch of layers into an OpenGL FBO (the static ones). Then compositing dynamic layers with static ones, etc.

After all if it's a vector drawing application, you don't need to redraw everything at each user interaction.

Stringer Bell
I have to redraw everything OnScroll()
Milo
Could you render a large patch once (and then copy a suitable proportion or the large patch) or does it all change really frequently?
Jon Cage
@user146780: Does OnScroll() mean zooming in, zooming out? If you have to render everything at each time this event is triggered, this shouldn't be a problem: zooming in means less primitives to draw, zooming out means less pixels to blend.
Stringer Bell
No, it means GlTranslating everything by camera.x, camera.y as you might expect from a scroll bar
Milo