Skip to main content
gamedev.net
🔒 Locked

Sphere Texturing ...

Started by P3D-BrandonR Aug 14, 2006 at 3:33 PM 5 replies 2k views
Original Post
P3D-BrandonR
P3D-BrandonR
Hello everyone, I try not to post unless it's a last resort to not finding any info online or on these past forum posts. I'm stumped at the moment with the situation of Texturing a Sphere and getting it to look right. Here is what I'm trying to accomplish: Using Sphere mesh as a skybox. I have one created, and all the faces flipped so that they face inside, since thats where our view will be. Here is my problem: I have tried tiling a image inside this sphere now with varrying deminsions 512x256, 1024x512 etc. What ever texture I make in photoshop, it looks nice and crisp. Once applied to the sphere it's stretched to fit. I solved the pinching at the poles problem btw. It's just the over all image is strechted so much that my image looks blown up or zoomed in once in the program. I have tried inside of 3dmax to just tile the image say 5-10 times and it makes it look just like I want it. Yet of course once in the program I have the pinching at the poles again, but the rest looks good. Heh, at a lost here of how to get it to look exactly how I want. In closing: I know I could use a Cube map for a skybox, but the app I'm making is a 360 type view with no flooring, much like outter-space. So to get the effect I'm currently wanting a Sphere or Geo-Sphere is what I'm working with currently. Thx in advance, -Brandon
smitty1276
smitty1276
That's the nature of spheres. Have you ever looked at a sphere map? They are only "unstretched" at the point where the normal is directly toward viewer, and become infinitely compressed around the edges. If your sphere map doesn't look like this, you will get the opposite effect.

EDIT: How did you go about fixing the convergence at the pole?

EDIT AGAIN: Also, what's wrong with a cube map? A cube map covers 360 degrees. I don't understand the comment about the floor.
jollyjeffers
jollyjeffers
Moving to GP&T as this is more of a general graphics question than one specific to D3D...

Texturing a sphere isn't simple - you will have to use an unwrapping algorithm (check out the "uv atlas" sample/API in the SDK, it'll do a reasonable job of this but its hard to tie it into something like Photoshop) or accept some artefacts.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
hplus0603
hplus0603
There are multiple possible solutions.

1) Use a cube map.

2) Use more than one texture, one for each cardinal direction (similar to a skybox).

3) Map the texture planar on top of the sphere, and make sure the ground covers the bottom half of the sphere when rendered (maybe just cut it out).

4) Actually use a skybox instead.
enum Bool { True, False, FileNotFound };
Thr33d
Thr33d
You *do* know that, by the nature (read: mathematics) of it, a skybox (ie interior of a cube) won't *appear* to be a cube at all (if done correctly)
right? :)

The only way you'll be able to tell (when done correctly) is if the resolution isn't high enough and you have detail that shows up antialiased at 1x1 px in the center and edges of the sybox....

Anyway, I'd recommend using the skybox via cubes method, seems to work rather well for all the purposes I've seen :)

-Michael g.

[Edited by - Thr33d on August 14, 2006 6:34:14 PM]
cpiasminc
cpiasminc
If you're dead set on using a sphere, then I've generally had good results with latitude/longitude mapping arrangements. They tend to have a warpage to the map that is inverse to the stretching and pinching that occurs on a sphere.

You can do conversions to such a map (say from a cubemap) with HDRShop. Or if you're more curious, you can look at HDRIE (downloadable from www.acm.uiuc.edu/siggraph), which is opensource, and you can see how the conversion actually works.

The way these conversions are done might look a little weird at first glance, but when we did it, the point was to decrease code volume as opposed to the brute force approach of every possible conversion.. The idea is to base it around the idea that for a given direction, knowing the probe format, we can determine a position in the image, and vice versa. So converting from one probe layout to another is simply to get the direction for a pixel position in the target layout and get the position of that direction from the source layout and sample that value (using whatever interpolation scheme). For the purposes of getting the mapping coordinates, you can just look at the direction->position routine for the chosen layout.
Light travels faster than sound. This is why many people appear very bright until they speak.
P3D-BrandonR
P3D-BrandonR
Thx so much for the comments.

And sorry about posting in wrong forum. I guess I do need to try the cube a little more. I guess I was set on the sphere idea from one of the DX9 books I had where there was a implementation of each. I'm not that experienced in the skyboxes, this is my first as you can see.

Oh and smitty. I was able to stop the pinching at the poles by simply using the Filter->Distort->Polar Coordinates [Polar to Square] ... then flip, rinse, and repeat. Granted its not the best method but it did stop the ugly pinching effect at the poles.

But thank you so much everyone for your responses. Much appreciated. I have some cube map patterns I will try tommorrow and see what I can come up with.

Oh and cpiasminc, I'll give that a look see too. That sounds very interesting. I'm all about learning.

Thanks,
-Brandon

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.