# Empty Sphere

This topic is 3839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I create a sphere that is not filled (I want to draw other things inside the sphere? Thanks

##### Share on other sites
Well, mathematically a filled sphere is given by
(x-x0)2 + (y-y0)2 + (z-z0)2 - R2 <= 0
while a hollow sphere is given by
(x-x0)2 + (y-y0)2 + (z-z0)2 - R2 == 0

But I assume that is not the answer you are expecting. The problem is, however, that I don't know _what_ you're expecting... What is the context, and how do you construct a solid sphere opposed to the hollow sphere? OpenGL, as any other rendering API, deals with surfaces only (the 2nd formula above).

A sphere is a 2-manifold, and hence rendering a sphere with an opaque material doesn't depend on its solidness. It becomes different only when you make a hole into the surface. (And, of course, its physical behaviour is different whether it is solid of hollow.)

If you want to see objects inside the sphere, you have to use transparency. From a physical point of view you need to simulate refraction, but that isn't easy. However, the refraction really depends on whether the sphere is hollow or not.

##### Share on other sites
Maybe he means drawing a transparent sphere. Then it could be as follows:

1. draw the back faces of the sphere, i.e. inner side (if the sphere is wound CCW then changing front faces temporarily to GL_CW would do the job).
2. draw the the objects inside the sphere
3. draw the front faces of the sphere, i.e. outer side

For steps 1 and 3, blending has to be enabled.
Step 2 can be done before step 1 if the objects aren't transparent. Doing so would save some overdraw (hidden pixels of the inner side not drawn).

##### Share on other sites
GL deals with points, lines, triangles. That's all.
If you are going to render a filled sphere or any other polygonal surface for that matter, I'm guessing you mean
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

and to make it unfilled

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

##### Share on other sites
Quote:
 Original post by Lord_EvilMaybe he means drawing a transparent sphere. Then it could be as follows:1. draw the back faces of the sphere, i.e. inner side (if the sphere is wound CCW then changing front faces temporarily to GL_CW would do the job). 2. draw the the objects inside the sphere3. draw the front faces of the sphere, i.e. outer sideFor steps 1 and 3, blending has to be enabled.Step 2 can be done before step 1 if the objects aren't transparent. Doing so would save some overdraw (hidden pixels of the inner side not drawn).

Ah, yes, "filled" in the sense of z-buffer values disallowing depth test passing ... good point.

Just for completion: Rendering transparent objects with z-buffer enabled requires the objects to be rendered in the order from back to front. In the given case the surface of the sphere has to be divided up into 2 shells, one behind and one in front of the contained objects. Lord_Evil's suggestion does that by rendering the sphere twice.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634087
• Total Posts
3015444
×