PDA

View Full Version : blending incorrect triangles



ale211734
01-21-2015, 06:29 AM
Hello everyone,
I'm trying to render an object in transparency. What I should do is render the same object in two different positions, in the first rendering the object should be opaque and the second rendering must be transparent.
I have tried simply to render the transparent object but I see an incorrect rendering of triangles scattered and do not understand why

My code have the depth test enabled and the pseudocode is similar to this:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
glColor (x, x, x, 100);
renderObject (no triangles ordered)

1600

uwi2k2
01-22-2015, 12:46 AM
hi,

it looks like both objets are in exacly same place ..
that would lead to so calld "z-fighting".
Just keep in mind that a transpernt pixel still writes some depth information ...
Blending can only work properbly id objects are drawn from back to front.
Can you upload a picture of a single object ? as it is hard to see were object 1 starts and 2 ends.

regards
uwi2k2

ale211734
01-22-2015, 01:11 AM
hi,

it looks like both objets are in exacly same place ..
that would lead to so calld "z-fighting".
Just keep in mind that a transpernt pixel still writes some depth information ...
Blending can only work properbly id objects are drawn from back to front.
Can you upload a picture of a single object ? as it is hard to see were object 1 starts and 2 ends.

regards
uwi2k2

Hello uwi2k2,

in the picture you can see a single object: it's a tooth in blending mode. Are blending wrong if I draw a single object with depth buffer enabled without
order the triangles object from back to front? All triangles object are draw with the same color and the same alpha value.
I attach another picture where I remove the code lines
/*glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);*/
1601

uwi2k2
01-22-2015, 01:45 AM
hi,

ok - got it..
than you should try: glCullFace() and hide backfaces ... it this works fine .. than the order of the triangles it really the problem ...
than you need some complex logic to order tem.

cu
uwi2k2

ale211734
01-22-2015, 05:35 AM
hi,

ok - got it..
than you should try: glCullFace() and hide backfaces ... it this works fine .. than the order of the triangles it really the problem ...
than you need some complex logic to order tem.

cu
uwi2k2

now added

glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);

does not work even if the problem is minimized.

The problem is depend from the viewer position and I can rotate the trackball in positions where I have this problem, and in positions where everything seems ok. This picture is rendered in a position where I can see this problem (GL_CULL_FACE enabled)1602