PDA

View Full Version : Skyboxes and corners...



fshana
12-05-2000, 01:41 PM
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...

Don't Disturb
12-05-2000, 02:39 PM
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).]

fshana
12-05-2000, 06:17 PM
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 ?

Tom Nuydens
12-06-2000, 12:22 AM
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

Nutty
12-06-2000, 01:14 AM
Whats Bryce? And where can I get it from?

cheers,
Nutty

DFrey
12-06-2000, 03:24 AM
See this: http://www.gamasutra.com/features/visual_arts/19981023/skybox_05.htm

Michael Steinberg
12-06-2000, 06:02 AM
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).]

pleopard
12-06-2000, 08:33 AM
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.

fshana
12-06-2000, 04:38 PM
I tried the cylinder approach. I still get stupid corners though.

12-06-2000, 08:37 PM
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.

Tom Nuydens
12-07-2000, 12:09 AM
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?

I got Bryce 2 for free with a PC Format CD a long time ago. The latest version (4) costs $200.

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

Michael Steinberg
12-07-2000, 04:22 AM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif

Tom Nuydens
12-07-2000, 06:56 AM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif

Ah, now I'm starting to catch your drift http://www.opengl.org/discussion_boards/ubb/smile.gif
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 http://www.opengl.org/discussion_boards/ubb/wink.gif

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

pleopard
12-07-2000, 07:12 AM
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

cass
12-08-2000, 07:29 AM
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).

mcraighead
12-08-2000, 07:59 AM
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

El Jefe
12-08-2000, 09:08 AM
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..

cass
12-08-2000, 12:41 PM
Ugh. You're right Matt.

fshana
12-08-2000, 07:56 PM
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

haigu
12-09-2000, 06:48 AM
How to export the sky in Bryce?

12-09-2000, 07:13 AM
The link already posted in this thread tells
you exactly that.

http://www.gamasutra.com/features/visual_arts/19981023/skybox_05.htm

fshana
12-09-2000, 08:05 AM
Oh, one other thing, where can I get an eval of Bryce? The version on Corel's site costs $200 !!!

DFrey
12-09-2000, 10:09 AM
I found an old evaluation release of Bryce 2 at ftp://ftp.ogo.ru/pub/cooler.irk.ru/BRYCE/bryce2.zip

It doesn't seem to save the rendered images though. That however, doesn't stop one from taking screen shots and cropping the results.



[This message has been edited by DFrey (edited 12-09-2000).]

12-10-2000, 05:33 PM
If you want a very capable and FREE program
for generating sky boxes (or any kind of
high-quality 3D scenes) try Persistence of
Vision. It has a very capable scene
description language (unfortunately, it's
left-handed, so you'll have to swap your Z
when thinking about it :-)

There's also a shareware modeler for Windows
called Moray, although last I checked it
didn't do meshes very well.

Setting up a script to render a scene with
90 degree FOV in six directions for using in
a skybox is child's play using POV-Ray. http://www.povray.org/

Post-scriptum, not intended as an attack on
anyone personally:

It has been said that the problem of piracy
is that it hurts the small developer and
solidifies the market leader. After all, if
you steal some software, because "you cannot
afford the price of the market leader," you
will steal the market leader's software
(might as well steal the biggest).

If stealing was just not an option, period,
then the people who can't afford the biggest
would buy some cheaper solution, typically
from some smaller developer. Thus, piracy
(stealing) hurts the little guys the most.

Tom Nuydens
12-11-2000, 12:50 AM
A very good, semi-free terrain rendering tool that you should also look into is Terragen (http://www.planetside.co.uk/terragen).

- Tom

Michael Steinberg
12-11-2000, 03:44 AM
Oh, to that glittering of the stars. You could scale the texture map to be half as big in either direction. It will definetely glitter, and you won't have to big textures. You could also make that resolution dependent.

Kilam Malik
12-11-2000, 05:32 AM
Could you render Skyboxes with terragen now? I got version 0.81 and I didn't find something like that.

Tom Nuydens
12-11-2000, 08:13 AM
Originally posted by Kilam Malik:
Could you render Skyboxes with terragen now? I got version 0.81 and I didn't find something like that.

Any 3D app that allows you to move and rotate the camera can be used to render skyboxes. I don't think I've ever actually tried this in Terragen, but I did succesfully do it in Bryce and Vistapro, so I don't see why Terragen should be any different. I'll be sure to check, though http://www.opengl.org/discussion_boards/ubb/smile.gif

- Tom

haigu
12-11-2000, 06:26 PM
Would sky domes look better than sky boxes?
If so, how could I export the dome modeled in Bryce?

12-12-2000, 12:03 PM
Not really. If you have enough texture
resolution for your skybox, there should be
very minimal distortion. Even a 256x256x6
skybox looks pretty good in 800x600 with
linear texture interpolation.

If you're currently calling glClear to clear
your color buffer to black (or something)
consider putting your skybox drawing code
there instead (since it'll overdraw the
entire screen). Turn off depth testing when
you draw it, and just draw it as a unit cube.
Then call glClear() with depth and stencil
buffer bits and start rendering the rest of
your scene.

Works like a charm for me, and took all of
an hour to implement, 30 minutes of which was
getting the textures to look nice in POV :-)