1 / 32

Sky Rendering

Sky Rendering. The actual physics is very complicated and costly to calculate. Several cheap approaches for very distant skies: Constant backdrop Skybox – outer box with the viewer inside. Skydome – outer hemi-sphere with the viewer inside. Sky box.

amandap
Télécharger la présentation

Sky Rendering

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 Rendering • The actual physics is very complicated and costly to calculate. • Several cheap approaches for very distant skies: • Constant backdrop • Skybox – outer box with the viewer inside. • Skydome – outer hemi-sphere with the viewer inside.

  2. Sky box • Start with a box (or half-box) that covers your world. • Ensure that the camera stays within this box.

  3. Skybox • Map textures to box. Top Back Left Front Right

  4. Skydome • Use a hemi-sphere instead. • Search web for textures.

  5. n, f = distances to near, far planes e = focal length = 1 / tan(FOV / 2) a = viewport height / width OpenGL Projection Matrix

  6. Take limit as f goes to infinity Infinite Projection Matrix

  7. Directions are mapped to points on the infinitely distant far plane A direction is a 4D vector with w = 0 (and at least one nonzero x, y, z) Good for rendering sky objects Skybox, sun, moon, stars Infinite Projection Matrix

  8. The important fact is that z and w are equal after transformation to clip space: Infinite Projection Matrix

  9. After perspective divide, thez coordinate should be exactly 1.0, meaning that the projected point is precisely on the far plane: Infinite Projection Matrix

  10. Ordinarily, z is mapped from the range [−1, 1] in NDC to [0, 1] in viewport space by multiplying by 0.5 and adding 0.5 This operation can result in a loss of precision in the lowest bits Result is a depth slightly smaller than 1.0 or slightly bigger than 1.0 Infinite Projection Matrix

  11. If the viewport-space z coordinate is slightly bigger than 1.0, then fragment culling occurs The hardware thinks the fragments are beyond the far plane Can be corrected by enabling GL_DEPTH_CLAMP_NV, but this is a vendor-specific solution Infinite Projection Matrix

  12. Universal solution is to modify projection matrix so that viewport-space z is always slightly less than 1.0 for points on the far plane: Infinite Projection Matrix

  13. This matrix still maps the near planeto −1, but the infinite far plane is now mapped to 1 − e Infinite Projection Matrix

  14. Because we’re calculating e − 1 ande − 2, we need to choose so that 32-bit floating-point precision limits aren’t exceeded Infinite Projection Matrix

  15. Texture Atlas • Find patches on the 3D model • Place these (map them) on the texture map image. • Space them apart to avoid neighboring influences.

  16. Texture Atlas • Add the color image (or bump, …) to the texture map. • Each polygon, thus has two sets of coordinates: • x,y,z world • u,v texture

  17. Example 2

  18. Sprites and Billboards • Sprites – usually refer to 2D animated characters that move across the screen. • Like Pacman • Three types (or styles) of billboards • Screen-aligned (parallel to top of screen) • World aligned (allows for head-tilt) • Axial-aligned (not parallel to the screen)

  19. Creating Billboards in OpenGL • Annotated polygons do not exist with OpenGL 1.3 directly. • If you specify the billboards for one viewing direction, they will not work when rotated.

  20. Example

  21. Example 2 • The alpha test is required to remove the background. • More on this example when we look at depth textures.

  22. Re-orienting • Billboards need to be re-oriented as the camera moves. • This requires immediate mode (or a vertex shader program). • Can either: • Recalculate all of the geometry. • Change the transformation matrices.

  23. Re-calculating the Geometry • Need a projected point (say the lower-left), the projected up-direction, and the projected scale of the billboard. • Difficulties arise if weare looking directlyat the ground plane.

  24. Undo the Camera Rotations • Extract the projection and model view matrices. • Determine the pure rotation component of the combined matrix. • Take the inverse. • Multiply it by the current model-view matrix to undo the rotations.

  25. Screen-aligned Billboards • Alternatively, we can think of this as two rotations. • First rotate around the up-vector to get the normal of the billboard to point towards the eye. • Then rotate about a vector perpendicular to the new normal orientation and the new up-vector to align the top of the sprite with the edge of the screen. • This gives a more spherical orientation. • Useful for placing text on the screen.

  26. World Aligned Billboards • Allow for a final rotation about the eye-space z-axis to orient the billboard towards some world direction. • Allows for a head tilt.

  27. Lastra Example

  28. Lastra Example

  29. Axial-Aligned Billboards • The up-vector is constrained in world-space. • Rotation about the up vector to point normal towards the eye as much as possible. • Assuming a ground plane, and always perpendicular to that. • Typically used for trees.

More Related