1 / 15

Sky Boxes and Vector Math 2

Sky Boxes and Vector Math 2 . Course Information CVG: Programming 4 My Name: Mark Walsh Website: www.activehelix.co.uk/courses Recommended Reading Introduction to 3D Game Programming with DirectX 9.0 (Frank D. Luna). Sky Boxes: Introduction.

ishi
Download Presentation

Sky Boxes and Vector Math 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sky Boxes and Vector Math 2 Course Information • CVG: Programming 4 • My Name: Mark Walsh • Website: www.activehelix.co.uk/courses Recommended Reading • Introduction to 3D Game Programming with DirectX 9.0 (Frank D. Luna)

  2. Sky Boxes: Introduction • A skybox is a method to easily create a background to make a computer and video games level look bigger than it really is, by creating the illusion of distant three-dimensional surroundings • A skydome employs the same concept but uses either a sphere or a hemisphere instead of a cube • A sky box is a simple way to put 360 degrees of background around the user

  3. Skybox Advances • Processing of 3D graphics is very costly • Levels have to be processed at tremendous speeds, making it difficult to render vast skyscapes in real-time • Due to the nature of computer graphics, objects at large distances suffer from floating point errors, causing levels to have strong limits on their extents.

  4. To compensate for these problems, games often employ skyboxes • As a viewer moves through a 3-D scene, it is common for the skybox to remain stationary with respect to the viewer • This technique gives the skybox the illusion of being very far away since other objects in the scene appear to move, while the skybox does not. • This imitates real life, where distant objects such as clouds, stars and even mountains appear to be stationary when the viewpoint is displaced by relatively small distances. • Effectively, everything in a skybox will always appear to be infinitely distant from the viewer

  5. Advanced Skyboxes • The default skybox had disadvantages • It could not be animated and all objects in it appeared to be infinitely distant, even if they were close-by • In the late 1990s, some GDs built small amounts of 3D geometry to appear in the skybox to create a better illusion of depth, in addition to a traditional skybox for objects very far away. • This constructed skybox was placed in an unreachable location, typically outside the bounds of the playable portion of the level, to prevent players from entering the skybox.

  6. In older versions of this technology, such as presented in the game Unreal this was limited to movements in the sky, such as the movements of clouds • Elements could be changed from level to level • The skybox in this game would still appear to be infinitely far away as the skybox did not move the viewing point along with the player movement through the level.

  7. Newer engines, such as the Source engine, continue on this idea, allowing the skybox to move along with the player, although at a different speed • Making the skybox move slower than the level causes the skybox to appear far away, but not infinitely • The skybox actually is constructed almost as a miniature complete with its own skybox to maintain the illusion of an infinitely far sky • This miniature is often at a scale (the Source engine typically uses 1/16th) to compensate for the floating point errors.

  8. In the game Half-Life 2 this effect was extensively used in showing The Citadel • In the later half of the game, the player would eventually travel through the city towards the Citadel, the skybox effect making it grow larger and larger progressively with the player movement • In some instances, the Citadel is broken into 2 pieces • A small lower section is a part of the main map, while the upper section is in the skybox. The two sections are seamlessly blended together to appear as a single structure

  9. The simplest way to make one is to create six faces of a cube, textured on the inside • We often use the flexible vertex format (FVF) • The exact vertex format is up to you; it only must have position and tex coords • Some people add normals (A surface normal, or simply normal, to a flat surface is a vector which is perpendicular to that surface) and more

  10. Rendering Order • When you begin to render a frame, determine which faces are visible • Turn off lighting and z-buffering • Rotate the faces to match the player (or camera) rotation, and draw them.

  11. Metaphorically, this is a cube centred on the player (camera) that moves with him, but has fixed rotation (so the user can rotate within). • In other words, assuming you've got a player's position and rotation, apply the rotation but NOT the position to the WORLD transform before drawing.

  12. 1. The vertex winding is backwards from a normal cube, since the textures will be viewed from INSIDE (this matters if you're using culling only) • 2. The size of the cube is irrelevant, so long as every pixel of it is always within the clipping area (between the front and back clipping planes). • Its distance doesn't matter because the z-buffer is off, so everything rendered after the sky box goes right over it anyway.

  13. XFiles and SkyBoxes • It is possible to load a skybox from an X-File. • The skybox is defined in the x file as a cube with its insides textured with the sky and some sea. • A skybox can therefore be loaded in exactly the same way as other .x files • The difference in implementation comes in the render function.

  14. Rendering the Skybox • The view matrix is set each time the camera moves so when we come to render our skybox we need to: • Remember the current view matrix. To do this we can use the GetTransform function. • Change its position so the skybox is centred over us • Set the world matrix to identity • Render the skybox as we would for a normal .x file • Restore the original view matrix

  15. The End

More Related