Jump to content
  • Advertisement
Sign in to follow this  
mbanghart

Empty Sphere

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil
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).

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!