Skybox vs Skysphere
What are some advantages and disadvantages between the two. Especially for something l开发者_如何学编程ike a 3D game.
Skyboxes and skyspheres are pretty much equivalent in the sense that you will get the same kind of visual effect - i.e. a nice background that appears to be at a long distance away.
However I'd normally recommend a skybox for the following three reasons:
- Less polygons required
- Assuming you set up your projection matrices correctly, you can't tell that you are inside a box (if you get it wrong, you may see some distortions)
- It's easier to render square skybox images (one for each of the size directions)
Regarding the last point, it is pretty easy to configure a renderer to produce raytraced square images that exactly fit on a skybox by creating a 90 degree field of view, e.g. in POVRay you would use something like the following:
camera {
right -x
up y
direction -z
location 0
}
I typically use 1024*1024 or 2048*2048 square textures for this.
The one good reason I can think of to use a skysphere is if you are using some kind of procedural texture approach that requires generation at (approximately) the points on a unit sphere. I think that is a pretty special case however, and unlikely to be necessary for most gaming applications.
It is easier to make textures for skybox. Also polygon count will be smaller (but this is negligible with today cards).
The only problem with skybox is that the edges of the cube may be visible under certain conditions.
Another aspect that makes a difference:
- skybox will never collide with the geometry - the image is only projected from another camera that rotates together with the user camera and is "stuck in the box"
- in case of skysphere, the background will render directly (player can "bump into the sky")
A good description and OpenGL sample is here.
a skysphere is also very cool cause you can use any mercator projection map to texture it, and it have no distortion at all.
Another advantage of skyboxes is being able to use a cubemaps for them - sphere mapping on the other hand is not hardware accelerated (afaik).
when you are using a skybox, you most likely will use a box texture. This texture can also be used for reflective materials. Skyphere textures are not that easy to use here.
精彩评论