PDA

View Full Version : Weird overlap effect



Fezziwig
11-08-2012, 09:21 AM
When I enable depth testing in my program I get this weird overlap effect. I gather it's something to do with blending but I don't know much about texture blending.
http://i.imgur.com/vBAtP.png
In the picture examples of my problem are circled.

Any help is much appreciated!
Thanks,
Rowan.

PS: As you can tell from the picture my top down tree sprites are awful. Do you know where I can get some the look decent.

carsten neumann
11-08-2012, 01:47 PM
Looks to me as if your transparent objects are writing to the depth buffer and/or are not rendered from back to front.

Fezziwig
11-09-2012, 10:07 AM
Why shouldn't a transparent object write to depth buffer? How else am I meant to change the drawing order without major changes to my code?

Alfonse Reinheart
11-09-2012, 10:54 AM
Why shouldn't a transparent object write to depth buffer?

Because then the algorithm doesn't work.

If you draw something transparent into the depth buffer, and then draw something (transparent or opaque) behind it, OpenGL will dutifully not draw it at all.

OpenGL only knows about the triangle it's currently rendering and the framebuffer. It doesn't know what has been rendered "transparently" before.

This is a common, well-understand thing about transparency via blending. You must render all transparent objects last. You must turn off depth buffering, and you must sort transparent objects back-to-front. There is no other way to handle this.

uwi2k2
11-09-2012, 02:20 PM
Hi,

just an other idea.
maybe your blendfunc is not set correctly.

cu
uwi