- June 16, 2010 at 11:33 pm #30181
I am drawing one surface on the current scene. Then on the suface, I draw a line with normal the same as the surface but different color. Then I rotate the two targets at the same time. I usedglEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);So when the surface is rotating, it only shows me the front face. However, the line is still there when it rotated to the far side with a black line. I am wondering how to hide this line when it is rotating away with its back side. (see the attached image)Thank you very much,RenaissanceJune 17, 2010 at 10:03 am #34023
I’m afraid you can’t do face culling in OpenGL without a face so this doesn’t work with GL_LINEs. You will have to find another way of culling the lines, I’m afraid.
What kind of scene are you drawing in this way?June 17, 2010 at 9:55 pm #34024Thank you for your reply, Gordon.My application needs sevearl crosses on a rotating closed 3D surface as special indictors. I thought I just need to use GL_LINE to make the cross and it is done. However, the visible backside of the lines adds black noise when the crosses are on the other side of the surface.June 22, 2010 at 4:45 pm #34025
If you are able to draw lines then it’s probably going to be quite easy to render polygons with a textured icon or similar as a marker. The benefit of this is that these polygons will get face culled. Be careful of depth fighting issues.
Otherwise you are going to have to find some way of keeping track of which ploys are facing which way.June 22, 2010 at 5:29 pm #34026It seems that I could not get this issue solved and I am trying to use other method to construct the marker, as you suggested, a polygon.Thank you very much, Gordon.July 1, 2010 at 1:59 pm #34027
An alternative might be to give the vertices normals (the same for both endpoints), transform the normals correctly in the vertex shader and then set alpha 0 to zero in pixel shader if the transformed normal points into the negative z direction.July 7, 2010 at 9:52 am #34028
After reading Martin’s suggestion, I’ve considered this further and think that there maybe a way to do something in the vertex shader. If you have normals that are pointing in the direction that your polygon is facing it should be possible to test whether these are facing away from the camera. If the vertices for a line fail the test then they can be transformed to (0,0,0) and the graphics core will cull them away before reaching the fragment processing step and incurring the cost of fragment processing and blending.
Unfortunately, if one end of the line passes and one end fails (say if one end is in front of the camera and one end is behind) then this system will produce strange results.
Gordon 2010-07-07 09:54:19