Hi, let me describe the geometric situation first and the problem later:
I have to draw a sphere with a maximum radius circunference over it. Like an “equator line”, the center of the circunference is coincident with the center of the sphere. The sphere is translucid and the circunference is opaque.
The problem: In order to draw this scene with a high quality, using blending to produce the antialising, I need to draw things in the following sequence:
A semi-arc of circunference that will be almost “hidden” by the translucid sphere.
The entire translucid sphere.
The other semi-arc of circunference that can be directly viewed.
The reson for doing so is the apha blending for antialising.
My question is: How can I draw this?
If we first draw the sphere (with glDepthMask( GL_FALSE ) ) and then draw the circunference, the later will appear just as if it is in the front of the sphere.
If we first draw the circunference and the sphere later, the part of the circunference that can be viewed directly, won’t be properlly antialised (because it will be blended with the background, and not with the sphere).
Just know that the sphere is made of polygon faces, while the circunference is made of lines (so culling works just for polygon).
Thank you very much,
To me the simplest way would be to go for thin polygons instead of lines, so that you can actually use culling.
How can I do that?
Thanks for the answer!
I, my self, have found a possible solution. It works well, ar least.
Use a clip plane to cut the sphere throught its center. The plane must be parallel to the screen and with its back facing the viewer. Draw the entire scene then remove the clipping plane and draw everything again. Using glDepthTest and Display Lists made it fast (at least in my computer).
I hope someone give me an ideia if I am going throught the right way.
Thanks a lot,
Using a clip plane will probably give correct results (even if a bit overkill for your use).
I am not sure to understand well your algo though.
To me :
- activate clip plane parallel to the screen, passing throught sphere center, and cutting the world between plane and camera.
- draw the equatorial line (so only the back part is drawn)
- desactivate clip plane
- draw the sphere
- re-activate clip cplane, this time cuttin the world between the plane and the infinite far.
- draw the equatorial line (so only the front part is drawn)
If you don’t have performance problems, you can stick with it.
About using polygons instead of lines :
Just see your equator as a cylinder with both ends open, the same radius as your sphere, and a very small height. Finding the correct height seems the biggest problem. It should be about one pixel in screen size, so that may be hard to find with a wide fov and/or a moving camera.