home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8a_sdk.exe / samples / multimedia / direct3d / envmapping / spheremap / readme.txt < prev    next >
Encoding:
Text File  |  2000-09-22  |  2.7 KB  |  61 lines

  1. //-----------------------------------------------------------------------------
  2. // Name: SphereMap Direct3D Sample
  3. // 
  4. // Copyright (c) 1998-2000 Microsoft Corporation. All rights reserved.
  5. //-----------------------------------------------------------------------------
  6.  
  7.  
  8. Description
  9. ===========
  10.    The SphereMap sample demonstrates an enviroment-mapping technique called 
  11.    sphere-mapping. Environment-mapping is a technique in which the environment
  12.    surrounding a 3D object (such as the lights, etc.) are put into a texture
  13.    map, so that the object can have complex lighting effects without expensive
  14.    lighting calculations.
  15.  
  16.    Note that not all cards support all features for all the various environment
  17.    mapping techniques (such as cubemapping and projected textures). For more
  18.    information on environment mapping, cubemapping, and projected textures, 
  19.    refer to the DirectX SDK documentation. 
  20.  
  21.  
  22. Path
  23. ====
  24.    Source:     MSSDK\Samples\Multimedia\D3D\EnvMapping\SphereMap
  25.    Executable: MSSDK\Samples\Multimedia\D3D\Bin
  26.  
  27.  
  28. User's Guide
  29. ============
  30.    The following keys are implemented. The dropdown menus can be used for the
  31.    same controls.
  32.       <Enter>     Starts and stops the scene
  33.       <Space>     Advances the scene by a small increment
  34.       <F1>        Shows help or available commands.
  35.       <F2>        Prompts user to select a new rendering device or display mode
  36.       <Alt+Enter> Toggles between fullscreen and windowed modes
  37.       <Esc>       Exits the app.
  38.  
  39.  
  40. Programming Notes
  41. =================
  42.    Sphere-mapping uses a precomputed (at model time) texture map which contains
  43.    the entire environment as reflected by a chrome sphere. The idea is to
  44.    consider each vertex, compute it's normal, find where the normal matches up
  45.    on the chrome sphere, and then assign that texture coordinate to the vertex.
  46.  
  47.    Although the math is not complicated, this still involves computations for
  48.    each vertex for every frame. Fortunately, Direct3D has a texture-coordinate
  49.    generation feature that can be used to do this for us. The relevant
  50.    renderstate operation is D3DTSS_TCI_CAMERASPACENORMAL, which takes the
  51.    normal of the vertex in camera space and pumps it through a texture
  52.    transform to generate texture coordinates. We use this and simply set up our
  53.    texture matrix to do the rest. In this simple case, the matrix just has
  54.    to scale and translate the texture coordinates to get from camera space 
  55.    (-1, +1) to texture space (0,1).
  56.  
  57.    This sample makes use of common DirectX code (consisting of helper functions,
  58.    etc.) that is shared with other samples on the DirectX SDK. All common
  59.    headers and source code can be found in the following directory:
  60.       Mssdk\Samples\Multimedia\Common
  61.