# Skyboxes and corners...

Not sure if this is an advanced topic but here goes:
What is the correct way to implement a skybox?

Take a look at the following picture: http://www.cornflakezone.com/gallery.php?galleryitem=14

notice the sky has a visible corner in the center of the screen? What am I doing wrong?

The sky in this case is a dome shape, like the inside of a breakfast bowl. I disable the Depth test and draw it first before everything else, It’s also quite large, huge in fact compared to the models.

I’ve also seen people use a flat sky which is parallel to the ground and box in the sides at 90 degrees to one another but again I get the corners. I know someone can help me, I just never figured this simple thing out. There’s some trick I’m missing…

You have to predistort the textures to avoid this effect.
How you would do this precisely I don’t know (I just nick my textures from elsewhere).

If you have Bryce I think there’s a skybox generator in there.
To put the skybox at an infinite distance, just translate it to the position of the viewer (then you can make it as big or small as you like and it won’t make any difference (as long as it is within the clipping bounds)).

[This message has been edited by Don’t Disturb (edited 12-05-2000).]

Ehh, run that by me again, “pre-distort the textures” ? What do you mean by that ?

What about the parallel plane type skyboxes. Any ideas ?

You don’t need to distort anything. If you render your skybox as a cube, with its center exactly in the viewer’s position, it will look just dandy.

The only thing you need to take care of is that you render the six sides of your cube with a 90 degree FOV. Unfortunately, there’s a bug in Bryce, which causes the FOV to get slightly messed up. As such, you need to multiply your FOV by 1.25. So the FOV you need to assign to your camera in Bryce is 112.5 degrees.

Good luck

• Tom

Whats Bryce? And where can I get it from?

cheers,
Nutty

Tom, that is actually what is meant. If you distort it while creation of the textures or if you distort them afterwards is the same. (Where the first attempt should give better result though…)
To Bryce3D, how much does that cost? Is it payable?

[This message has been edited by Michael Steinberg (edited 12-06-2000).]

Another solution is to usr a really tall cylinder instead of a cube. Make it tall enough or restrict the camera pitch so that the viewer can’t see the top and the problem is solved. I used have used this approach with a single texture mapped onto a cylinder and with a single repeating texture mapped onto each quad of a cylinder. It works really well for me.

I tried the cylinder approach. I still get stupid corners though.

That is because you’re using a “straight”
texture that’s not fitted for skycube
mapping. The projection (or distortion) of a
texture for skycube mapping is similar to
that of cubic environment mapping.

Try getting a set of skycube textures for
QuakeII and stick that on your cube walls,
and see if that doesn’t help. The gamasutra
article pointed at by a previous poster is
also very useful, even though it’s aimed at
artists, not coders – mainly, because your
problem is one of the art you put in, not of
the code.

Originally posted by Michael Steinberg:
Tom, that is actually what is meant. If you distort it while creation of the textures or if you distort them afterwards is the same. (Where the first attempt should give better result though…)
To Bryce3D, how much does that cost? Is it payable?

Again, I really don’t see where you’re getting this ‘distortion’ thing. The images do not have to be distorted in any way. You just create a 3D scene, place a camera with a 90 degree FOV in it, and then render it six times. That’s all there’s to it.

It’s not like spherical environment maps or whatever, where you have to distort the rendered image to make it suitable for mapping onto a sphere. You have six bitmaps here, and none of them need to be warped in any way.

• Tom

Yeah Tom, from your point of view, that is actually correct. If one has got a 90degrees fov sky renderer that is cool.
But if you made a star background, just a plain image, with no 90degrees renderer, just with for example paint, you’ll need to distort that image, to make it look good on a box. Basically, it needs to get stretched at the corners, since they are more distant to the viewer. (At least that is the trick).
Actually it’s something like making a 90degrees fov into a plain image.

Originally posted by Michael Steinberg:
But if you made a star background, just a plain image, with no 90degrees renderer, just with for example paint, you’ll need to distort that image, to make it look good on a box. Basically, it needs to get stretched at the corners, since they are more distant to the viewer. (At least that is the trick).
Actually it’s something like making a 90degrees fov into a plain image.

Ah, now I’m starting to catch your drift
I’m so accustomed to the way I create skyboxes that I would probably fire up Bryce even if just to create a simple starfield. It just never occured to me that people might try to do it any other way

If Bryce is not an option, there’s a tool called SkyPaint (see the aforementioned Gamasutra article), which could be useful. I haven’t used it much myself, but it’s a combination of a standalone app and a Photoshop plugin. I don’t know if it’s very practical for anything other than retouching existing skyboxes, though.

• Tom

fshana your texture has to be ‘seamless’. That is, the left side pixels must match the right side pixels and the top pixels must match the bottom pixels. Some textures differ so radically from the left-right and top-bottom edges that they cannot be made seamless. Others can easily be doctored to be seamless. There are several ways to make a texture seamless, here is how I do it using Adobe PhotoShop:

Note the width (w) and height (h) of your image. From the “Filter” menu navigate to the sub-menu titled “Other” and select the “Offset” filter. A dialog will come up, in the ‘horizontal’ box type in one half of your width (w/2). In the ‘Vertical’ box type in h/2. Select the ‘Wrap Around’ option in the “Undefined Areas” selector and click ‘Ok’.

Next select the ‘clone’ tool from the toolbar and pick a brush size of a few pixels and 0 hardness. <alt>click a few pixels to either side of the vertical seam (now in the middle of the image) then release. Then start brusing up the seam. Do the same for the horizontal seam. When you are done, apply the offset filter again to get your image back to its original orientation. At this point you may need to clean up a little inside of the perimeter boundary of the image. Most likely, you will need to experiment an hour or so until you understand the process.

Good Luck!
Paul H. Leopard

If you’re using ARB_texture_cube_map to render your skybox, you should use a sphere to draw your “skybox” in the scene to reduce distortion due to interpolation of (s,t,r).

Cass, I don’t believe that’s necessary. You should just be able to draw a unit cube. Cube maps are “effectively” projectively textured, so it should just work if you use the exact same 3D coords for the vertex and for the texture coordinate.

• Matt

Hmmm, I tried using a cone for a while. As long as I translated the cone so that it was always in the same position relative to my view origin…then rotated it to match the changing view angles, I didn’t get any weird seams…at least as long as I made it about 32 sided…sigh…

Ugh. You’re right Matt.

32 sided is fine, it’s just more than I anticipated. I guess I can live with it and don’t have to go through all the hassle of generating warped textures. Thanks to all who explained this to me. I finally understand what you’re all talking about. Cheers,
fs

How to export the sky in Bryce?