View Full Version : Blending QUADS causes tesselation?
10-12-2000, 11:10 AM
I'm drawing boxes using QUADS. I draw them from +z to -z When I turn on anti-aliasing (using blending) I get "lines" diagonaly through the rectangles. I was wondering if someone could help, or point me in the correct direction.
10-12-2000, 01:57 PM
Blending is transparency, right? So are you seeing things through the squares? (Like the edges of squares behind the first).
10-12-2000, 04:29 PM
No. Blending is used for anti-aliasing.
I make the following calls:
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND );
glEnable( GL_POLYGON_SMOOTH );
10-12-2000, 10:45 PM
The recommended mode for polygon antialiasing uses SATURATE in the blending function. (See the red book for explanations.)
With saturation blending you have to sort from front to back and probably have to disable depth buffering, at least set a depth func which contains ...EQUAL, to get this working.
The problem with the depth is, that the coverage is calculated on color values in the alpha channel. If the z-buffer is set for a border pixel the adjacent polygon cannot add something to the coverage if the depth test fails.
The visual effect is that you get some halos around depth buffered antialiased primitives and the colors of those halos depend on the drawing order.
10-16-2000, 04:36 PM
I am rendering a box. I am using QUADS. I did the front side (+z) first then: top (+y), left (-x), bottom (-y), and right (+x), and finially the back (-z).
I have DEPTH_TEST enabled and the depth function set to LEQUAL (less than or equal to). But I still get diagonal "lines" in each face if I enabe blending.
Any help would be great. Thanks
10-16-2000, 08:34 PM
What happens if you disable DEPTH_TEST and use culling to ensure that only the front faces of your box draw?
Generally, POLYGON_SMOOTH is not meant to be used in combination with DEPTH_TEST. You get too many pixels with double hits.
It is pretty common for OpenGL implementations to break up quads and polygons into triangles and then render each triangle independently. If you set up the right blending, POLYGON_SMOOTH will still work, but if not, you'll see "split quads", as you are observing.
Reading the OpenGL spec 100% strictly, it is not OK to do this, but it's a rule that everyone breaks because it is just too expensive to implement a rasterizer for polygons with an arbitrary number of sides, especially if coverage values are required.
10-17-2000, 01:03 AM
did you use the GL_SRC_ALPHA_SATURATE blend func?
Have a look at Example 6-5 in the RedBook:
http://heron.cc.ukans.edu/ebt-bin/nph-dw..._RESTART_N%25#X (http://heron.cc.ukans.edu/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/@ebt-link;cs=fullhtml;pt=13383?target=%25N%15_13634_STA RT_RESTART_N%25#X)
10-17-2000, 09:23 AM
I turned off depth testing and only have culling turned on. Rectangles for box sorted -z to +z. Blend Func = ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ): Does not fix the problem. Although the box looks anti-aliased
I kept the depth test off. Set the Blend Func = ( GL_SRC_ALPHA_SATURATE , GL_ONE ). The object would disappear.
I sorted +z to -z. the box would appear, but the front & top was culled.
I'm thinking that I have the concept of winding reversed: If I look at the side I want to see the points should be couter-clockwise? (I have FrontFace set to GL_CCW).
I changed the FrontFace to CW, but that made the object "disappear" again.
I turned off culling the half-box would appear (only the bottom & back viewable).
Thanks for all quick responces so far guys. I'm new to OpenGL, and I assume I'm doing something silly.
10-17-2000, 03:18 PM
Here is more on the problem (I think)
I am using textures for my box.
If I setup glTexEnvi with GL_DECAL, everything is fine (just no lighting adjustment), but if I use GL_MODULATE I get an artifact that looks like a diaganel line through the rectannle. Actually it looks like one half(or triangle) has the texture in one direction and the other half has it in a different direction.
I hope someone can help me.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.