Sky boxes

Started by
1 comment, last by UnknownPlayer 21 years ago
What''s the best way to go about implementing sky boxes? Particularly in relation to a 3D space sim (what I''m writing) where ideally it''s impossible for the player to ever get past the sky box but it still seems as though its a textured sphere surrounding them (i.e. when they rotate around the stars and nebulas move appropriately). Any help would be really appreciated. ##UnknownPlayer##
##UnknownPlayer##
Advertisement
You just need to draw a cube centered in the camera, so when the camera moves, it won''t reach the cube''s sides. You don''t need to rotate it (the cube remains still).

For rendering the cube, IMO the best choice is to draw it before any other geometry, without depth writing/reading. The size of the cube doesn''t matter, just keep sure the vertices are inside the frustum.
-----DevZing Blog (in Spanish)
Turn off depth writing, rotate based on camera orientation, ( so transform to the cameras frame, but make sure it doesn''t include translation attributes, as this would enable you to fly out of the skybox ) and render the box. So:

1. Disable depth writing
2. Push and multiply modelview matrix by the camera frame ( excluding translation )
3. Render cube
4. Pop modelview matrix
5. Enable depth writing

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement