seamless sphere texture

Blitz3D Forums/Blitz3D Programming/seamless sphere texture

slenkar(Posted 2004) [#1]
I have a texture that is seamless, horizontally and vertically.
It looks great until I look at the poles of the sphere.

It looks like there is an obvious seam there at both ends.

It isnt warped like most sphere texture problems, its just that I can see where the polygons come to a point.

I have a high number of polygons (3000) and a high resolution texture 1024x1024


Rob(Posted 2004) [#2]
It isn't possible to seamlessly texture a sphere without some artifacting. If using one texture and one surface.

There are a few tricks you can pull by splitting the sphere into two halves and mapping each half - that will remove the distortion if you use two textures.

The problem you are having is a uv coordinate problem.


Ross C(Posted 2004) [#3]
You could use a geosphere. it's mapped like a cube, with 6 sides. Imagine a blown out cube.


slenkar(Posted 2004) [#4]
Thanks rob and ross

whats the easiest way to get a geosphere in blitz or wings3D?

I tried texturing a cube but it has one texture per face instead of covering the whole thing with 1 texture.

How do I force it to not tile the texture?


Ross C(Posted 2004) [#5]
Well, you have to really use 6 texture faces, like a skybox. You could stick them all on the one texture no problem tho :) As for how to make a geosphere, i can't remember which programs do this... Suppose you could just infate a sphere :)


slenkar(Posted 2004) [#6]
i tried using a dodechahedron but the texture loses all its details, its just one color!


Floyd(Posted 2004) [#7]
i tried using a dodechahedron but the texture loses all its details, its just one color!

That's what happens when a mesh has no UV values assigned.

U,V start out as 0,0 by default. If no other values are assigned the only texture pixel in use is the top-left one.


sswift(Posted 2004) [#8]
You guys are wrong. It is possible to texture a sphere without artifacts, you just need the right texture.

1. Open your image in photoshop.
2. Scale it up 2-4x. Bigger is better.
3. Go to Filter->Distort->Polar coordinates
4. Select Rectangular to Polar.

Note how the image looks weird. The crap in the middle is how the north pole would look on your sphere. Paint over this using the clone brush or whatever tool you wish to get rid of the seams.

Now to do the south pole.

1. Go to Filter->Distort->Polar coordinates
2. Select Polar to Rectangular.

This restores the image to nomal.

1. Go to Image->Canvas->Rotate->Flip Vertical
2. Go to Filter->Distort->Polar coordinates
3. Select Rectangular to Polar.

You are now looking at the south pole. Paint over the seams.

Now convert back to normal.

1. Go to Filter->Distort->Polar coordinates
2. Select Polar to Rectangular.

And finally, rescale your image back to it's original size.
The reason you scale it up, is because the polar transforms tend to reduce the resolution in some areas of the image, so that compensates for it.

You now have an image which looks smudged along the top and bottom, but this is correct, because those areas will be squeezed into a much smaller area.

Note that you may need to work a little more at this to get ir right, because a polygon sphere is imperfect, and the polar region isn't exactly the same mapping as it would be with an ideal sphere.


Rob(Posted 2004) [#9]
I am correct. your method requires abnormal detail levels and the resulting texture has a much lower pixel resolution per triangle real estate.


slenkar(Posted 2004) [#10]
Thanks SSwift I managed to find the same filter in GIMP and all I had to do was smudge the artifact a little and it looked nice and seamless, I forgot to scale up the image but Im sure after I do it again it will look fine,
thats a lot of work I managed to avoid getting 6 images for a skybox or 2 domes phew!


sswift(Posted 2004) [#11]
"I am correct. your method requires abnormal detail levels and the resulting texture has a much lower pixel resolution per triangle real estate."

I beg to differ.

1. The distortion and reduction of detail is minimal.
2. This method is easier.
3. You are wrong that you need to use two textures to map two halves of a sphere. Any mapping you can do with two textures, can be done with one. Two textures would make two surfaces and surfaces are expensive and should be minimized as much as possible.
4. The only mapping other than spherical mapping which you could be indicating that he use, would be planar mapping. Planar mapping a sphere would cause those areas near the equator to be stretched, and the corners of the texture would be unused, wasting texture resolution. You couldn't be suggesting cylyndrical mapping, because that would be possible without splitting the sphere in half.


sswift(Posted 2004) [#12]
"thats a lot of work I managed to avoid getting 6 images for a skybox or 2 domes phew!"

You know though, that two domes, or a skybox would give you better resolution. More textures = higher res.

In fact, I suggest you use a skybox. Six textures will provide much greater resolution than one, which is especially important on cards that only support 256x256 textures.

There are functions in the code archives I think which you could use to say, make a HUGE spherical texture, (4096x4096) texture a sphere with it, and then render a skybox from the inside, so that you can use six smaller textures so as to be nicer to voodoo cards.

Just a suggestion.


slenkar(Posted 2004) [#13]
Say I had a canvas that I rendered some clouds on and made it tilable, would there be an easy way to get 6 skybox textures from it in photoshop??

I used a 1024x1024 texture and made it 4x bigger for distorting but it still looked a little blocky.
My PC almost died during the rendering too!


sswift(Posted 2004) [#14]
Well you can paint a skybox in photoshop, though it's a bit of a pain to do so... but there's no way I know of to distort it so that those sections near the corners are stretched properly to take the additional distance at which they will be from the camera into account. Without that stretching, the sky will probably look like a cube.


Mustang(Posted 2004) [#15]
Spheres and spheriacal mapping does not work "right" mainly because topmost polygons in the sphere (or hemisphere) are triangles and everything below it are "quads" (two triangles)... quads can have continuous UVs and "seamless border", but single triangle in this case can't - either you get saw-teeth pattern or most likely pinched one point on the top of the UV where those single triangles connect... if you overlay your actual map on top of that you can see that it won't work because those top triangles don't have "seamless borders".

Here's what I do: I do additional "knifing" at the VERY top of the hemishere, ie zoom as close as I can get to the top point and divide the polygons just nanometers below it; result is that I have now pushed the border where quad becomes single polygon higher. After that I need usually only to paint the top 1-2 pixels from the spherical map using single (matching) color to get things look real nice.


sswift(Posted 2004) [#16]
"I do additional "knifing" at the VERY top of the hemishere, ie zoom as close as I can get to the top point and divide the polygons just nanometers below it;"

Um... wouldn't that just result in a bunch of degenerate triangles, which are really really thin? If you take a quad, divide it along it's diagonal, and then squeeze the top two points together, one of the triangles becomes really thin. I fail to see how this improves the mapping.


Mustang(Posted 2004) [#17]
wouldn't that just result in a bunch of degenerate triangles, which are really really thin?


Yes, but those will be on the 1-2 pixel space of the UV maps top - which I just color "uniformly".


Beaker(Posted 2004) [#18]
Might be of interest:
http://skypaint.com/


Mustang(Posted 2004) [#19]
Lees excellent Tattoo can be used also for sky painting if you wish to do that instead of trying to fix UVs.

http://www.terabit.nildram.co.uk/tattoo


slenkar(Posted 2004) [#20]
that skypaint looks good but I only have GIMP which doesnt accept photoshop plugins.Tattoo is nice but I already spent 40 dollars on UU.

I managed to discover that I can create Geospheres in Ultimate Unwrap but the UV mapping is a pain, any tips?


sswift(Posted 2004) [#21]
"Yes, but those will be on the 1-2 pixel space of the UV maps top - which I just color "uniformly".

That doesn't make sense.

I am not talking about the tiny polygons at the very top of the sphere. I am talking about the "quads" if you can even call them that, that you claim improve the texturing that you create just below by subdividing the polygons one more time near the top. Those "qauds" would have degenerate triangles on one side of each quad with the other being formed by a regular triangle.


Mustang(Posted 2004) [#22]
Ummm... below is the sphere BEFORE cutting close to the top-point... as you can see (the yellow lines) the top will be screwed (imagine spherical sky texture on top of the UV window wireframe) because there is "teething" and triangles dont share borders.



After the surgery you have intact "quads" again and the "teething" area with troublesome "screwed" triangles are limited to the 1-2 topmost pixels on the map (UV-window). If you have clouds for example on the top-point, you just paint the 1-2 top pixels in pure white (or whatever your cloud color is) and you have nice working sky sphere.

This method has worked well in all the projects I have used hemispheres and have needed the ability to look straight up.




slenkar(Posted 2004) [#23]
I tried smudging it using tattoo but the smudge is distorted,


slenkar(Posted 2004) [#24]
I found out that Brad Bolthouses free tool allows you to paint on an image with polar co-ords and there is minimal loss of resolution..www.unwrap3d.com


sswift(Posted 2004) [#25]
Mustang, I still am not convinced...



Take a look at that image there...
Now, ignoring the thin line, take a look at the top left quad.

Now, that is not actually a quad, it's actually two triangles. We'll say it's split from top left to bottom right.

Now, imaigne how that quad is mapped to the sphere. The top os squished very small compared to the bottom.

That being the case, the triangle on the right side of the quad, the one with the wide part near the top, will become very thin, and everything in that area will be squished... So each "quad" at the top of your sphere is really one regular triangle, and one very squished triangle.


Now take a look at this image:



See how the top comes to a single point? That is the important difference between the first and the second pic.

But you don't need to create a nother line of quads to fix that. The problem is that all the triangles at the top of the sphere in your mapping share a single vertex. If they each had one vertex of their own, which would be less expensive than creating additional quads, then you could make those triangles at the top look like half a quad each, and they would not have a tiny almost infinitely thin triangle squished between them potentially creeating rendering artifacts, and just adding extra polygons.

All this is a moot point though, because I can't think of any good reason to use a hemisphere rather than half a skybox. A skybox has fewer polygons, no problems with seams at all, and allows you to use more textures so your sky is higher res. The additional surfaces required is so miniscule that it's not worth being concerned with.


WolRon(Posted 2004) [#26]
Why all of the fuss about spherical mapping.

Just use a geosphere. They use less polygons anyways.


slenkar(Posted 2004) [#27]
how do you map the texture to the geosphere?


Mustang(Posted 2004) [#28]
Mustang, I still am not convinced...


You don't have to be - I am, and that's enough for me! :P

One more try:









Skymap image is 2048*512, and I have painted one pixel high uniform color band on top and bottom to smooth out problem areas (average color of top pixel row). Bottom pixel row is important to remember too because real-time UVs can easily bleed unless UVs are clamped (& center of pixel problems, bilinear filtering).

By looking at the images it's clear IMO that knifing helps to fix the problematic mapping of top part of the sphere.

Note that these shots have been downscaled (and are jpgs) and were taken directly from lightwave which supports only 1K textures in OGL viewports.


sswift(Posted 2004) [#29]
Well Mustang, I just tried your method in 3D Studio, and I could not replicate the results which you've gotten. As I suspected, cutting close to the pole, and then arranging the UV coordinates as you have, did not have any effect at all on the final result.

In fact, one thing I thougth WOULD improve the final result, tellelating the sphere 4x as much, had no effect at all on the seams at the top.

The fact tesselating the sphere more had no effect at all on the final result puzzles me. If your method, does in fact work, which it appears to in Maya, then surely tesselating the sphere more should have the exact same effect that you are getting. So why does it not work in max?

Perhaps you should try using a skybox that has a ceiling that has more contrast in it. The one you'r eusing is mostly white, whereas the one I'm using has much darker areas mixed in with the white. I would be interested to see how what you're doing handles something more difficult to get seamless.


Mustang(Posted 2004) [#30]
surely tesselating the sphere more should have the exact same effect that you are getting.


Nope... tesselating does not help the top. You need to reduce the area of the topmost triangles (that are not "quads") to zero and thus eliminate the problem of UV-mapping something that can't be UV-mapped properly in this case. When I knife the top I do that nano millimeters below the absolute top point thus making the troublesome top triangles vanish because they became more like a vertexlike spot than area made out of polygons.

All polygons below that are "true quads / triangle pair with shared neighbours" and can be mapped "right" like you can see from my example... they ARE quite thin though and the mapping angle is quite low, almost parallel to the polygons, but it usually does not matter.

Of course the results are even better (well perfect) if you use something like Tattoo to smooth out few remaining visual problems... and usually it's good to choose cloud/skymap that has single color on the top point, like white cloud or blue sky even in my method.

If you want to take a look at yourself:

http://www.caffeineoverdose.net/zips/Skyspheres.rar

RAR has both spheres I used for the above example shots, with mappings, but no skymap texturemap. And they are in .LWO format of course.

You can use these freely in your projects... sphere size is 200m / 200 Blitz3D units (radius), surface name is "Default" and the UV-map name is "Texture" (both LW default name values). And texture I used was named "sky2.tga".


sswift(Posted 2004) [#31]
"You need to reduce the area of the topmost triangles (that are not "quads") to zero and thus eliminate the problem of UV-mapping something that can't be UV-mapped properly in this case."

But if you tesselate the sphere more, then the triangles at the top will be smaller, and take up a smaller area with quads being closer to the top.

But what I saw, was that even though the tringles near the top of the sphere were quads, they still displayed the exact same problems with seams showing up. I checked the UV mapping and adjusted it and I could not fix the problem.

I understand that you reduced the size of the triangles at the top to almost a point. But I'm not talking about those. If I deleted those triangles, there would still be an area near the top of the sphere that isn't mapped properly even when I have tesselated it a lot more.

I guess I'll see if I can take a look at your model and see if it looks different in max.


sswift(Posted 2004) [#32]
Poo. I can't load them into max, or into poser to re-save them as 3DS. Could someone convert them? :-)


Mustang(Posted 2004) [#33]
www.caffeineoverdose.net/zips/Skyspheres_3ds.rar :)

...These are exported from the Lightwave modeler using its built-in 3DS exporter. Models may be rotated 90 deg etc funny stuff - and if the mappings are really all over the place its probably exporters fault. :)