SlideShare ist ein Scribd-Unternehmen logo
1 von 80
Downloaden Sie, um offline zu lesen
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
               Programming techniques for First Person Shooters in
started
                                  DirectX 9
.map
format and
visibility
test

func plat
meshes
                                  Alejandro Cosin Ayerbe
A bit on
materials

Parallax
mapping
with
multiple
                                    August 2012
point lights

Bibliography
Introduction

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9      This presentation is an abstract of my final project in Computer Engineering,
                presented in September of 2006. There were several goals in this project, the
Introduction    main ones are the following:
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Introduction

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9      This presentation is an abstract of my final project in Computer Engineering,
                presented in September of 2006. There were several goals in this project, the
Introduction    main ones are the following:
Getting
started

.map                Understand how first person shooter video games work: level mesh
format and
visibility          management, BSP trees, inter-area portals, visibility tests, static simple
test
                    and complex meshes, mesh rendering, skeletal animation, light
func plat
meshes              positioning, materials....
A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Introduction

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9      This presentation is an abstract of my final project in Computer Engineering,
                presented in September of 2006. There were several goals in this project, the
Introduction    main ones are the following:
Getting
started

.map                Understand how first person shooter video games work: level mesh
format and
visibility          management, BSP trees, inter-area portals, visibility tests, static simple
test
                    and complex meshes, mesh rendering, skeletal animation, light
func plat
meshes              positioning, materials....
A bit on            Develop programming techniques centered in performance (particularly
materials
                    for visibility tests).
Parallax
mapping
with
multiple
point lights

Bibliography
Introduction

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9      This presentation is an abstract of my final project in Computer Engineering,
                presented in September of 2006. There were several goals in this project, the
Introduction    main ones are the following:
Getting
started

.map                Understand how first person shooter video games work: level mesh
format and
visibility          management, BSP trees, inter-area portals, visibility tests, static simple
test
                    and complex meshes, mesh rendering, skeletal animation, light
func plat
meshes              positioning, materials....
A bit on            Develop programming techniques centered in performance (particularly
materials
                    for visibility tests).
Parallax
mapping
with
                    Learn differences between the graphics programming APIs OpenGL and
multiple
point lights
                    DirectX.
Bibliography
Introduction

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9      This presentation is an abstract of my final project in Computer Engineering,
                presented in September of 2006. There were several goals in this project, the
Introduction    main ones are the following:
Getting
started

.map                Understand how first person shooter video games work: level mesh
format and
visibility          management, BSP trees, inter-area portals, visibility tests, static simple
test
                    and complex meshes, mesh rendering, skeletal animation, light
func plat
meshes              positioning, materials....
A bit on            Develop programming techniques centered in performance (particularly
materials
                    for visibility tests).
Parallax
mapping
with
                    Learn differences between the graphics programming APIs OpenGL and
multiple
point lights
                    DirectX.
Bibliography        Perform per-pixel lighting effects like specular and parallax mapping.
Programming    In an attempt to know in depth the performance of the current FPS games,
techniques
  for First    level, mesh and geometric model loaders were looked for.
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    In an attempt to know in depth the performance of the current FPS games,
techniques
  for First    level, mesh and geometric model loaders were looked for.
   Person
Shooters in
 DirectX 9
               In general in the game industry, the formats are proprietary, so usually there is
               no access to this type of information.
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    In an attempt to know in depth the performance of the current FPS games,
techniques
  for First    level, mesh and geometric model loaders were looked for.
   Person
Shooters in
 DirectX 9
               In general in the game industry, the formats are proprietary, so usually there is
               no access to this type of information.
Introduction

Getting
started        Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal
.map           animation player were found in Internet. Both of them were programmed in
format and
visibility     OpenGL, so there was no problem to use the data structures generated by
test
               them, but the rendering process in DirectX had to be programmed.
func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    In an attempt to know in depth the performance of the current FPS games,
techniques
  for First    level, mesh and geometric model loaders were looked for.
   Person
Shooters in
 DirectX 9
               In general in the game industry, the formats are proprietary, so usually there is
               no access to this type of information.
Introduction

Getting
started        Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal
.map           animation player were found in Internet. Both of them were programmed in
format and
visibility     OpenGL, so there was no problem to use the data structures generated by
test
               them, but the rendering process in DirectX had to be programmed.
func plat
meshes

A bit on
               The level viewer works with .map format, was developed by Miguel Angel
materials      Pastor, aka Garrofi. His old homepage is all that can be found today. If you
Parallax
mapping
               want the source code of the level viewer, contact me at
with           aca_1983_@hotmail.com and i will send it to you, as there are no active links
multiple
point lights   for download. The mesh viewer and animator player works with .md5 format
Bibliography   (md5mesh for meshes and md5anim for animations), and can be downloaded
               here.
Programming    In an attempt to know in depth the performance of the current FPS games,
techniques
  for First    level, mesh and geometric model loaders were looked for.
   Person
Shooters in
 DirectX 9
               In general in the game industry, the formats are proprietary, so usually there is
               no access to this type of information.
Introduction

Getting
started        Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal
.map           animation player were found in Internet. Both of them were programmed in
format and
visibility     OpenGL, so there was no problem to use the data structures generated by
test
               them, but the rendering process in DirectX had to be programmed.
func plat
meshes

A bit on
               The level viewer works with .map format, was developed by Miguel Angel
materials      Pastor, aka Garrofi. His old homepage is all that can be found today. If you
Parallax
mapping
               want the source code of the level viewer, contact me at
with           aca_1983_@hotmail.com and i will send it to you, as there are no active links
multiple
point lights   for download. The mesh viewer and animator player works with .md5 format
Bibliography   (md5mesh for meshes and md5anim for animations), and can be downloaded
               here.

               Information about .map file format and .md5 file format can be read here and
               here respectively.
Getting started

Programming
techniques      Doom 3 was programmed in OpenGL, so a rendering process in DirectX
  for First
   Person       required some changes, like texture coordinates, which are different in each
Shooters in
 DirectX 9
                API, or the coordinate systems used.

Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Getting started

Programming
techniques      Doom 3 was programmed in OpenGL, so a rendering process in DirectX
  for First
   Person       required some changes, like texture coordinates, which are different in each
Shooters in
 DirectX 9
                API, or the coordinate systems used.

Introduction    Starting from an empty demo from the DirectX 9 SDK, the meshes of the
Getting         models where correctly rendered through index buffers and texturized.
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Getting started

Programming
techniques      Doom 3 was programmed in OpenGL, so a rendering process in DirectX
  for First
   Person       required some changes, like texture coordinates, which are different in each
Shooters in
 DirectX 9
                API, or the coordinate systems used.

Introduction    Starting from an empty demo from the DirectX 9 SDK, the meshes of the
Getting         models where correctly rendered through index buffers and texturized.
started

.map
format and
                These meshes are very optimized, for example, weapon meshes exclude those
visibility
test
                polygons from the mesh that never are viewed:
func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
               md5 meshes include the weapons carried by the player, so a first person
Shooters in
 DirectX 9
               shooter needs to render correctly those meshes when the camera moves. The
               problem was to make these meshes rotate correctly:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
               md5 meshes include the weapons carried by the player, so a first person
Shooters in
 DirectX 9
               shooter needs to render correctly those meshes when the camera moves. The
               problem was to make these meshes rotate correctly:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
               md5 meshes include the weapons carried by the player, so a first person
Shooters in
 DirectX 9
               shooter needs to render correctly those meshes when the camera moves. The
               problem was to make these meshes rotate correctly:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights   The solution was to decompose the view matrix in its scaling, rotation and
Bibliography   translation factors when rendering each frame. The rotation factor, given by a
               quaternion, was then used to rotate correctly the weapon mesh and therefore
               give the appearance that the weapon follows the camera.
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes
               Also a head up display was made, enabling alpha blending and disabling depth
A bit on       testing in order to keep the HUD visible even if the camera walks through a
materials      mesh. The number textures were taken from the Doom 3 textures, while some
Parallax
mapping
               simple symbols were made with Photoshop:
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes
               Also a head up display was made, enabling alpha blending and disabling depth
A bit on       testing in order to keep the HUD visible even if the camera walks through a
materials      mesh. The number textures were taken from the Doom 3 textures, while some
Parallax
mapping
               simple symbols were made with Photoshop:
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
               In FPS games, weapons have some typical animations associated: firing,
mapping        reloading, idle, raise, lower... For the case of the shotgun in Doom 3, the
with
multiple       animations available are the following:
point lights
               empty.md5anim, fire1.md5anim, fire2.md5anim, fire3.md5anim,
Bibliography
               idle.md5anim, lower.md5anim, raise.md5anim, reload_end.md5anim,
               reload_loop.md5anim, reload_loop2.md5anim, reload_loop3.md5anim,
               and reload_start.md5anim.
Programming
techniques
  for First
   Person      If a realistic behaviour is wanted, a logical coordination of the animations is
Shooters in
 DirectX 9     needed, so for the case of the shotgun, the first step is to play the raise
               animation, and when it ends, play the idle animation until player presses the
Introduction   reload or fire buttons, playing the corresponding animations and using
Getting        randomness if more than one animation is available for the current action, and
started
               taking into account the ammo.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      If a realistic behaviour is wanted, a logical coordination of the animations is
Shooters in
 DirectX 9     needed, so for the case of the shotgun, the first step is to play the raise
               animation, and when it ends, play the idle animation until player presses the
Introduction   reload or fire buttons, playing the corresponding animations and using
Getting        randomness if more than one animation is available for the current action, and
started
               taking into account the ammo.
.map
format and
visibility
test
               The fire effect in the barrel of the weapon is achieved using a texture like the
func plat
               following:
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      If a realistic behaviour is wanted, a logical coordination of the animations is
Shooters in
 DirectX 9     needed, so for the case of the shotgun, the first step is to play the raise
               animation, and when it ends, play the idle animation until player presses the
Introduction   reload or fire buttons, playing the corresponding animations and using
Getting        randomness if more than one animation is available for the current action, and
started
               taking into account the ammo.
.map
format and
visibility
test
               The fire effect in the barrel of the weapon is achieved using a texture like the
func plat
               following:
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      If a realistic behaviour is wanted, a logical coordination of the animations is
Shooters in
 DirectX 9     needed, so for the case of the shotgun, the first step is to play the raise
               animation, and when it ends, play the idle animation until player presses the
Introduction   reload or fire buttons, playing the corresponding animations and using
Getting        randomness if more than one animation is available for the current action, and
started
               taking into account the ammo.
.map
format and
visibility
test
               The fire effect in the barrel of the weapon is achieved using a texture like the
func plat
               following:
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights   This texture consists in a series of sprites that must be shown correctly,
Bibliography   averaging the number of frames of the fire animation and showing the
               appropriate portion of sprite in the correct interval. The sprites are displayed
               in a plane mesh available in every weapon:
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
                Doom 3 levels consist in four file formats:
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
                Doom 3 levels consist in four file formats:
format and
visibility          The MAP file, an ASCII text file with all the static geometry and entities,
test
                    such as lights, patches (Bezier surfaces), brushes (simple geometric
func plat
meshes              meshes) and the location of complex meshes whose geometry is loaded
A bit on            from files in a more general format (LWO for example).
materials

Parallax
mapping
with
multiple
point lights

Bibliography
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
                Doom 3 levels consist in four file formats:
format and
visibility          The MAP file, an ASCII text file with all the static geometry and entities,
test
                    such as lights, patches (Bezier surfaces), brushes (simple geometric
func plat
meshes              meshes) and the location of complex meshes whose geometry is loaded
A bit on            from files in a more general format (LWO for example).
materials

Parallax
                    The CM file, which stores the collision model data.
mapping
with
multiple
point lights

Bibliography
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
                Doom 3 levels consist in four file formats:
format and
visibility          The MAP file, an ASCII text file with all the static geometry and entities,
test
                    such as lights, patches (Bezier surfaces), brushes (simple geometric
func plat
meshes              meshes) and the location of complex meshes whose geometry is loaded
A bit on            from files in a more general format (LWO for example).
materials

Parallax
                    The CM file, which stores the collision model data.
mapping
with                The PROC file, with all the preprocessed geometry in the map, portal
multiple
point lights        information (Doom 3 operates with BSP-trees) and pre-calculated
Bibliography        shadow volumes (for static lights in static geometry).
.map format and visibility test

Programming
techniques
  for First
   Person
Shooters in     The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads
 DirectX 9
                most of the objects and entities of the level. Consists of more than 12000
                lines of source code, and generates a data structure somewhat complex, as the
Introduction
                amount and diversity of data is high.
Getting
started

.map
                Doom 3 levels consist in four file formats:
format and
visibility          The MAP file, an ASCII text file with all the static geometry and entities,
test
                    such as lights, patches (Bezier surfaces), brushes (simple geometric
func plat
meshes              meshes) and the location of complex meshes whose geometry is loaded
A bit on            from files in a more general format (LWO for example).
materials

Parallax
                    The CM file, which stores the collision model data.
mapping
with                The PROC file, with all the preprocessed geometry in the map, portal
multiple
point lights        information (Doom 3 operates with BSP-trees) and pre-calculated
Bibliography        shadow volumes (for static lights in static geometry).
                    The AAS files, used by the AI to move the monsters in the scenario.
Developing an efficient visibility test

Programming
techniques
                Once all the level geometry is loaded, and in order to optimize performance, a
  for First     criteria must be followed to know what meshes must be rendered (among
   Person
Shooters in     those visible for the camera, i.e., inside the view frustum), and what must not.
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Developing an efficient visibility test

Programming
techniques
                Once all the level geometry is loaded, and in order to optimize performance, a
  for First     criteria must be followed to know what meshes must be rendered (among
   Person
Shooters in     those visible for the camera, i.e., inside the view frustum), and what must not.
 DirectX 9


                Doom 3 levels use the BSP-tree system which divides a space into convex
Introduction
                sets. Each convex set is called in this case an area, and two areas are
Getting
started         connected through an IAP or Inter Area Portal. An example of the IAPs
.map            present in a Doom 3 level can be seen below:
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Developing an efficient visibility test

Programming
techniques
                Once all the level geometry is loaded, and in order to optimize performance, a
  for First     criteria must be followed to know what meshes must be rendered (among
   Person
Shooters in     those visible for the camera, i.e., inside the view frustum), and what must not.
 DirectX 9


                Doom 3 levels use the BSP-tree system which divides a space into convex
Introduction
                sets. Each convex set is called in this case an area, and two areas are
Getting
started         connected through an IAP or Inter Area Portal. An example of the IAPs
.map            present in a Doom 3 level can be seen below:
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
               Those IAP (seen from above) have different sizes and not always consist of
 DirectX 9     four vertices. Thinking of IAPs as if they were windows, candidate meshes to
               be rendered will be those in the areas whose IAPs can be seen from the
Introduction   camera position and orientation. Also, BSP-trees allow to determine easily
Getting        which area a given point belongs to, so finding the area in which the camera is
started
               located is simple.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
               Those IAP (seen from above) have different sizes and not always consist of
 DirectX 9     four vertices. Thinking of IAPs as if they were windows, candidate meshes to
               be rendered will be those in the areas whose IAPs can be seen from the
Introduction   camera position and orientation. Also, BSP-trees allow to determine easily
Getting        which area a given point belongs to, so finding the area in which the camera is
started
               located is simple.
.map
format and
visibility
test           The faster the method, the better the performance, because the visibility test
func plat      must be done every frame before the rendering process. There are several
meshes
               ways to test what surfaces are visible in a scenario based on BSP-trees,
A bit on
materials      currently there are several efficient methods, but new ways can be thought of?
Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
               Those IAP (seen from above) have different sizes and not always consist of
 DirectX 9     four vertices. Thinking of IAPs as if they were windows, candidate meshes to
               be rendered will be those in the areas whose IAPs can be seen from the
Introduction   camera position and orientation. Also, BSP-trees allow to determine easily
Getting        which area a given point belongs to, so finding the area in which the camera is
started
               located is simple.
.map
format and
visibility
test           The faster the method, the better the performance, because the visibility test
func plat      must be done every frame before the rendering process. There are several
meshes
               ways to test what surfaces are visible in a scenario based on BSP-trees,
A bit on
materials      currently there are several efficient methods, but new ways can be thought of?
Parallax
mapping
with
               The main task is to determine which IAPs of the current area are visible from
multiple
point lights
               the position and orientation of the camera, the meshes in those areas are the
Bibliography
               candidate meshes to be rendered. The hardware technique occlusion culling
               can be used (a detailed explanation can be found here), in oder to know what
               IAPs are visible.
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9



Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:

Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction
                        Render again the mesh to the small buffer (or bounding box).
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction
                        Render again the mesh to the small buffer (or bounding box).
                        Finish the query
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction
                        Render again the mesh to the small buffer (or bounding box).
                        Finish the query
Getting
started                 Retrieve information from the test: if the number of visible pixels is greater
.map
                        than cero, the mesh is visible from the camera position and orientation.
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction
                        Render again the mesh to the small buffer (or bounding box).
                        Finish the query
Getting
started                 Retrieve information from the test: if the number of visible pixels is greater
.map
                        than cero, the mesh is visible from the camera position and orientation.
format and
visibility
test           The following is an example of the method. On the left several IAPs can be
func plat      seen in green color. On the right, the content of the small buffer after
meshes
               performing the visibility test to one of the IAPs in the left:
A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    The concept is very simple:
techniques
  for First        Render to a small buffer the meshes being tested (or a bunding box for
   Person
Shooters in        performance).
 DirectX 9         For each mesh:
                        Start the query.
Introduction
                        Render again the mesh to the small buffer (or bounding box).
                        Finish the query
Getting
started                 Retrieve information from the test: if the number of visible pixels is greater
.map
                        than cero, the mesh is visible from the camera position and orientation.
format and
visibility
test           The following is an example of the method. On the left several IAPs can be
func plat      seen in green color. On the right, the content of the small buffer after
meshes
               performing the visibility test to one of the IAPs in the left:
A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    This way, starting from the area in which lies the camera, all the visible IAPs
techniques
  for First    for that area can be known. But the IAPs from other areas are visible from
   Person
Shooters in
               the current area sometimes, so the test must be refined, a way to improve the
 DirectX 9     test is described below.

Introduction
               For each visible IAP of the current area, tested with the occlusion culling test
Getting
started
               (which will be called culled IAP), do the following:
.map                Consider all the IAPs in the area accessed through the current culled IAP,
format and
visibility
                    which will be called secondary IAPs.
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    This way, starting from the area in which lies the camera, all the visible IAPs
techniques
  for First    for that area can be known. But the IAPs from other areas are visible from
   Person
Shooters in
               the current area sometimes, so the test must be refined, a way to improve the
 DirectX 9     test is described below.

Introduction
               For each visible IAP of the current area, tested with the occlusion culling test
Getting
started
               (which will be called culled IAP), do the following:
.map                Consider all the IAPs in the area accessed through the current culled IAP,
format and
visibility
                    which will be called secondary IAPs.
test                Trace straight lines from the corners and center of each secondary IAP to
func plat
meshes
                    the camera, and check if any of the lines intersect with the culled IAP.
A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    This way, starting from the area in which lies the camera, all the visible IAPs
techniques
  for First    for that area can be known. But the IAPs from other areas are visible from
   Person
Shooters in
               the current area sometimes, so the test must be refined, a way to improve the
 DirectX 9     test is described below.

Introduction
               For each visible IAP of the current area, tested with the occlusion culling test
Getting
started
               (which will be called culled IAP), do the following:
.map                Consider all the IAPs in the area accessed through the current culled IAP,
format and
visibility
                    which will be called secondary IAPs.
test                Trace straight lines from the corners and center of each secondary IAP to
func plat
meshes
                    the camera, and check if any of the lines intersect with the culled IAP.
A bit on
                    If there is at least a line verifying the condition, then that secondary IAP
materials           is visible through the current culled IAP. The next image shows a scheme:
Parallax
mapping
with
multiple
point lights

Bibliography
Programming    This way, starting from the area in which lies the camera, all the visible IAPs
techniques
  for First    for that area can be known. But the IAPs from other areas are visible from
   Person
Shooters in
               the current area sometimes, so the test must be refined, a way to improve the
 DirectX 9     test is described below.

Introduction
               For each visible IAP of the current area, tested with the occlusion culling test
Getting
started
               (which will be called culled IAP), do the following:
.map                Consider all the IAPs in the area accessed through the current culled IAP,
format and
visibility
                    which will be called secondary IAPs.
test                Trace straight lines from the corners and center of each secondary IAP to
func plat
meshes
                    the camera, and check if any of the lines intersect with the culled IAP.
A bit on
                    If there is at least a line verifying the condition, then that secondary IAP
materials           is visible through the current culled IAP. The next image shows a scheme:
Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction   Each time an IAP turns out to be visible, its IAP path is saved, as this
Getting        process iterates with tertiary and more distant IAPs. When making a
started
               tertiary IAP test, for example, the straight lines from the corners and
.map
format and     center of the IAP must intersect with its corresponding secondary and
visibility
test
               culled IAPs.
func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction   Each time an IAP turns out to be visible, its IAP path is saved, as this
Getting        process iterates with tertiary and more distant IAPs. When making a
started
               tertiary IAP test, for example, the straight lines from the corners and
.map
format and     center of the IAP must intersect with its corresponding secondary and
visibility
test
               culled IAPs.
func plat
meshes
               The test goes on with quaternary and more distant IAPs (whenever there
A bit on
materials      are remaining tests). At the end, there is a list of areas which are visible
Parallax       from the current camera position and orientation, so the meshes present
mapping
with           in those areas are the candidates to be rendered.
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      Now its time to test the visibility of each mesh in the visible areas. The test is
Shooters in
 DirectX 9
               slightly different, as meshes are tridimensional objects: for a given area and a
               given mesh in that area, straight lines from each corner and the center of the
Introduction
               bounding box of the mesh are traced to the camera.
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      Now its time to test the visibility of each mesh in the visible areas. The test is
Shooters in
 DirectX 9
               slightly different, as meshes are tridimensional objects: for a given area and a
               given mesh in that area, straight lines from each corner and the center of the
Introduction
               bounding box of the mesh are traced to the camera.
Getting
started        If any of these lines intersect with all the IAPs of the corresponding IAP path
.map
format and
               for the area in which the mesh lies, then that mesh is visible.
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person      Now its time to test the visibility of each mesh in the visible areas. The test is
Shooters in
 DirectX 9
               slightly different, as meshes are tridimensional objects: for a given area and a
               given mesh in that area, straight lines from each corner and the center of the
Introduction
               bounding box of the mesh are traced to the camera.
Getting
started        If any of these lines intersect with all the IAPs of the corresponding IAP path
.map
format and
               for the area in which the mesh lies, then that mesh is visible.
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques     Each time a mesh passes the test, is added to a vector of meshes. Once the
  for First
   Person      test ends, the vector is sorted by the depth of the z coordinate of the
Shooters in
 DirectX 9     bounding box.

Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques     Each time a mesh passes the test, is added to a vector of meshes. Once the
  for First
   Person      test ends, the vector is sorted by the depth of the z coordinate of the
Shooters in
 DirectX 9     bounding box.

Introduction   This method can be improved: below, on the left, an IAP can be seen in dark
Getting        brown. Depending on the form of the bounding boxes of the meshes being
started
               tested, the visibility test can fail, as can be seen in the image on the right.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques     Each time a mesh passes the test, is added to a vector of meshes. Once the
  for First
   Person      test ends, the vector is sorted by the depth of the z coordinate of the
Shooters in
 DirectX 9     bounding box.

Introduction   This method can be improved: below, on the left, an IAP can be seen in dark
Getting        brown. Depending on the form of the bounding boxes of the meshes being
started
               tested, the visibility test can fail, as can be seen in the image on the right.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    A way to fix this is to add a small error bound, to mark as visible those
techniques
  for First    meshes which don’t pass the test for a little. Now the same mesh of the
   Person
Shooters in
               previous image becomes visible. Small spheres corresponding with the corners
 DirectX 9     and the center point are rendered, giving an idea of the geometry of this type
               of simple meshes:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    A way to fix this is to add a small error bound, to mark as visible those
techniques
  for First    meshes which don’t pass the test for a little. Now the same mesh of the
   Person
Shooters in
               previous image becomes visible. Small spheres corresponding with the corners
 DirectX 9     and the center point are rendered, giving an idea of the geometry of this type
               of simple meshes:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    Another improvement was introduced by considering the camera as a
techniques
  for First    tridimensional object: the camera position is a single point, but the camera
   Person
Shooters in
               itself constitutes an area, so the test lines were aimed to the corners and
 DirectX 9     center point of the camera.

Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    Another improvement was introduced by considering the camera as a
techniques
  for First    tridimensional object: the camera position is a single point, but the camera
   Person
Shooters in
               itself constitutes an area, so the test lines were aimed to the corners and
 DirectX 9     center point of the camera.

Introduction
               This way, when the central point of the camera is in front of a wall, the visible
Getting
started
               meshes farther than the wall pass the visibility test.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming    Another improvement was introduced by considering the camera as a
techniques
  for First    tridimensional object: the camera position is a single point, but the camera
   Person
Shooters in
               itself constitutes an area, so the test lines were aimed to the corners and
 DirectX 9     center point of the camera.

Introduction
               This way, when the central point of the camera is in front of a wall, the visible
Getting
started
               meshes farther than the wall pass the visibility test.
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
func plat meshes

Programming
techniques      Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear.
  for First
   Person
                Some are complex meshes which must be loaded through an external file in
Shooters in
 DirectX 9
                .LWO or .ASE format, and others are the platforms and mobile meshes:
                elevators, doors...
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
func plat meshes

Programming
techniques      Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear.
  for First
   Person
                Some are complex meshes which must be loaded through an external file in
Shooters in
 DirectX 9
                .LWO or .ASE format, and others are the platforms and mobile meshes:
                elevators, doors...
Introduction

Getting
                These meshes don’t belong to a particular area, so a test to find out which
started         areas belong had to be done, and in the visibility test, test each of these
.map            surfaces only once. The results for non-specific-area meshes were satisfactory:
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
func plat meshes

Programming
techniques      Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear.
  for First
   Person
                Some are complex meshes which must be loaded through an external file in
Shooters in
 DirectX 9
                .LWO or .ASE format, and others are the platforms and mobile meshes:
                elevators, doors...
Introduction

Getting
                These meshes don’t belong to a particular area, so a test to find out which
started         areas belong had to be done, and in the visibility test, test each of these
.map            surfaces only once. The results for non-specific-area meshes were satisfactory:
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of
                this materials is built with specific keywords, which are detailed here and here.
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of
                this materials is built with specific keywords, which are detailed here and here.
Introduction

Getting
started         In order to perform some per-pixel effects, height, normal and specular maps
.map            are needed for each mesh, besides the traditional diffuse map. Doom 3
format and
visibility
                incorporates this textures, specified for each mesh in its definition.
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of
                this materials is built with specific keywords, which are detailed here and here.
Introduction

Getting
started         In order to perform some per-pixel effects, height, normal and specular maps
.map            are needed for each mesh, besides the traditional diffuse map. Doom 3
format and
visibility
                incorporates this textures, specified for each mesh in its definition.
test

func plat
meshes
                By parsing all the .mtr files (Doom 3 uses more than 2600 different
A bit on
                materials), the correct textures can be assigned to each mesh, although only
materials       simple per-pixel effects were made, like specular and parallax mapping or
Parallax        per-pixel lighting (due to lack of time).
mapping
with
multiple
point lights

Bibliography
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of
                this materials is built with specific keywords, which are detailed here and here.
Introduction

Getting
started         In order to perform some per-pixel effects, height, normal and specular maps
.map            are needed for each mesh, besides the traditional diffuse map. Doom 3
format and
visibility
                incorporates this textures, specified for each mesh in its definition.
test

func plat
meshes
                By parsing all the .mtr files (Doom 3 uses more than 2600 different
A bit on
                materials), the correct textures can be assigned to each mesh, although only
materials       simple per-pixel effects were made, like specular and parallax mapping or
Parallax        per-pixel lighting (due to lack of time).
mapping
with
multiple
point lights    Textures were loaded from a Zip file, an article in Gamedev explains how to do
Bibliography    this (can be read here).
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                The next image shows on the left some meshes. The same meshes, with
                standard per-pixel lighting, are shown on the right (point lights are described
Introduction
                as entities of type light in the file .map, with color and radius assigned):
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
A bit on materials

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                The next image shows on the left some meshes. The same meshes, with
                standard per-pixel lighting, are shown on the right (point lights are described
Introduction
                as entities of type light in the file .map, with color and radius assigned):
Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Parallax mapping with multiple point lights

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Parallax mapping produces a great effect of realism, and its computational
                cost is not exorbitant. The effect developed is based on the Parallax mapping
Introduction
                demo from this web, which had in the past didactic material on DirectX
Getting
started         (email me at aca_1983_@hotmail.com and i will send this demo to you).
.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Parallax mapping with multiple point lights

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Parallax mapping produces a great effect of realism, and its computational
                cost is not exorbitant. The effect developed is based on the Parallax mapping
Introduction
                demo from this web, which had in the past didactic material on DirectX
Getting
started         (email me at aca_1983_@hotmail.com and i will send this demo to you).
.map
format and
visibility      This application was programmed in 2006, when the most extended Shader
test
                Model was the 2.0. This Shader Model had a limit of 96 registers and 64
func plat
meshes
                instructions, so the limit for the effect was three passes (for three different
A bit on
                point lights).
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Parallax mapping with multiple point lights

Programming
techniques
  for First
   Person
Shooters in
 DirectX 9
                Parallax mapping produces a great effect of realism, and its computational
                cost is not exorbitant. The effect developed is based on the Parallax mapping
Introduction
                demo from this web, which had in the past didactic material on DirectX
Getting
started         (email me at aca_1983_@hotmail.com and i will send this demo to you).
.map
format and
visibility      This application was programmed in 2006, when the most extended Shader
test
                Model was the 2.0. This Shader Model had a limit of 96 registers and 64
func plat
meshes
                instructions, so the limit for the effect was three passes (for three different
A bit on
                point lights).
materials

Parallax
mapping
                If more than three point lights light a mesh, is neccessary to activate blending
with            (which means a drop in performance) and repeat the effect until all the
multiple
point lights    contributions on all the lights have been calculated.
Bibliography
Programming
techniques
  for First
   Person
Shooters in    The following image shows the parallax mapping effect, with a maximum of
 DirectX 9
               three point lights for each mesh on the left, and for more than three point
               lights in the right:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
Shooters in    The following image shows the parallax mapping effect, with a maximum of
 DirectX 9
               three point lights for each mesh on the left, and for more than three point
               lights in the right:
Introduction

Getting
started

.map
format and
visibility
test

func plat
meshes

A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography
Programming
techniques
  for First
   Person
                                                 Bibliography
Shooters in
 DirectX 9
               Ultimate Game Programming Allen Sherrod.
               http://www.ultimategameprogramming.com, September 2006.
Introduction

Getting        GameDev.net Developer Community.
started
               http://www.gamedev.net, September 2006.
.map
format and
visibility     Md5 mesh viewer in OpenGL David Henry.
test
               http://tfc.duke.free.fr, September 2006.
func plat
meshes
               Occlusion Culling Using DirectX 9 Dustin Franklin.
A bit on
materials      http://www.gamedev.net, September 2006.
Parallax
mapping        MAP file format.
with
multiple       http://www.modwiki.net, September 2006.
point lights

Bibliography   MD5 file format.
               http://www.modwiki.net, September 2006.

               Loading a Texture From a Zip File in DirectX 9 Greg Stewart.
               http://www.gamedev.net, September 2006.
Programming
techniques
  for First
   Person
Shooters in
 DirectX 9



Introduction

Getting
started
               Global material keywords.
.map
format and     http://www.modwiki.net, September 2006.
visibility
test
               Game Tutorials.
func plat
meshes         http://www.gametutorials.com, September 2006.
A bit on
materials

Parallax
mapping
with
multiple
point lights

Bibliography

Weitere ähnliche Inhalte

Ähnlich wie Programming techniques for First Person Shooters in DirectX 9

Uncharted3 effect technique
Uncharted3 effect techniqueUncharted3 effect technique
Uncharted3 effect techniqueMinGeun Park
 
Ha4 displaying 3 d polygon animations
Ha4   displaying 3 d polygon animationsHa4   displaying 3 d polygon animations
Ha4 displaying 3 d polygon animationsJordanSmith96
 
BigDL webinar - Deep Learning Library for Spark
BigDL webinar - Deep Learning Library for SparkBigDL webinar - Deep Learning Library for Spark
BigDL webinar - Deep Learning Library for SparkDESMOND YUEN
 
Augmented Reality with Open Source Software
Augmented Reality with Open Source SoftwareAugmented Reality with Open Source Software
Augmented Reality with Open Source Softwarenobby
 
metal-sketch-dojo.pptx
metal-sketch-dojo.pptxmetal-sketch-dojo.pptx
metal-sketch-dojo.pptxfrbf8y262q
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko3D
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glchangehee lee
 
Creative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkCreative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkHuijie Wu
 
ngGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and TokyongGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and Tokyonotolab
 
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Codemotion
 
The GAME that never was
The GAME that never wasThe GAME that never was
The GAME that never wasRogan Flitton
 
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfJIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfSamiraKids
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMark Kilgard
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark Kilgard
 

Ähnlich wie Programming techniques for First Person Shooters in DirectX 9 (20)

Blender
BlenderBlender
Blender
 
Pixel shaders
Pixel shadersPixel shaders
Pixel shaders
 
Uncharted3 effect technique
Uncharted3 effect techniqueUncharted3 effect technique
Uncharted3 effect technique
 
Pixel shaders
Pixel shadersPixel shaders
Pixel shaders
 
Ha4 displaying 3 d polygon animations
Ha4   displaying 3 d polygon animationsHa4   displaying 3 d polygon animations
Ha4 displaying 3 d polygon animations
 
BigDL webinar - Deep Learning Library for Spark
BigDL webinar - Deep Learning Library for SparkBigDL webinar - Deep Learning Library for Spark
BigDL webinar - Deep Learning Library for Spark
 
Augmented Reality with Open Source Software
Augmented Reality with Open Source SoftwareAugmented Reality with Open Source Software
Augmented Reality with Open Source Software
 
metal-sketch-dojo.pptx
metal-sketch-dojo.pptxmetal-sketch-dojo.pptx
metal-sketch-dojo.pptx
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSL
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_gl
 
Creative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkCreative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling Framework
 
Android native gl
Android native glAndroid native gl
Android native gl
 
ngGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and TokyongGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and Tokyo
 
What is OpenGL ?
What is OpenGL ?What is OpenGL ?
What is OpenGL ?
 
livingin3d
livingin3dlivingin3d
livingin3d
 
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
 
The GAME that never was
The GAME that never wasThe GAME that never was
The GAME that never was
 
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfJIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to Vulkan
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 

Programming techniques for First Person Shooters in DirectX 9

  • 1. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting Programming techniques for First Person Shooters in started DirectX 9 .map format and visibility test func plat meshes Alejandro Cosin Ayerbe A bit on materials Parallax mapping with multiple August 2012 point lights Bibliography
  • 2. Introduction Programming techniques for First Person Shooters in DirectX 9 This presentation is an abstract of my final project in Computer Engineering, presented in September of 2006. There were several goals in this project, the Introduction main ones are the following: Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 3. Introduction Programming techniques for First Person Shooters in DirectX 9 This presentation is an abstract of my final project in Computer Engineering, presented in September of 2006. There were several goals in this project, the Introduction main ones are the following: Getting started .map Understand how first person shooter video games work: level mesh format and visibility management, BSP trees, inter-area portals, visibility tests, static simple test and complex meshes, mesh rendering, skeletal animation, light func plat meshes positioning, materials.... A bit on materials Parallax mapping with multiple point lights Bibliography
  • 4. Introduction Programming techniques for First Person Shooters in DirectX 9 This presentation is an abstract of my final project in Computer Engineering, presented in September of 2006. There were several goals in this project, the Introduction main ones are the following: Getting started .map Understand how first person shooter video games work: level mesh format and visibility management, BSP trees, inter-area portals, visibility tests, static simple test and complex meshes, mesh rendering, skeletal animation, light func plat meshes positioning, materials.... A bit on Develop programming techniques centered in performance (particularly materials for visibility tests). Parallax mapping with multiple point lights Bibliography
  • 5. Introduction Programming techniques for First Person Shooters in DirectX 9 This presentation is an abstract of my final project in Computer Engineering, presented in September of 2006. There were several goals in this project, the Introduction main ones are the following: Getting started .map Understand how first person shooter video games work: level mesh format and visibility management, BSP trees, inter-area portals, visibility tests, static simple test and complex meshes, mesh rendering, skeletal animation, light func plat meshes positioning, materials.... A bit on Develop programming techniques centered in performance (particularly materials for visibility tests). Parallax mapping with Learn differences between the graphics programming APIs OpenGL and multiple point lights DirectX. Bibliography
  • 6. Introduction Programming techniques for First Person Shooters in DirectX 9 This presentation is an abstract of my final project in Computer Engineering, presented in September of 2006. There were several goals in this project, the Introduction main ones are the following: Getting started .map Understand how first person shooter video games work: level mesh format and visibility management, BSP trees, inter-area portals, visibility tests, static simple test and complex meshes, mesh rendering, skeletal animation, light func plat meshes positioning, materials.... A bit on Develop programming techniques centered in performance (particularly materials for visibility tests). Parallax mapping with Learn differences between the graphics programming APIs OpenGL and multiple point lights DirectX. Bibliography Perform per-pixel lighting effects like specular and parallax mapping.
  • 7. Programming In an attempt to know in depth the performance of the current FPS games, techniques for First level, mesh and geometric model loaders were looked for. Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 8. Programming In an attempt to know in depth the performance of the current FPS games, techniques for First level, mesh and geometric model loaders were looked for. Person Shooters in DirectX 9 In general in the game industry, the formats are proprietary, so usually there is no access to this type of information. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 9. Programming In an attempt to know in depth the performance of the current FPS games, techniques for First level, mesh and geometric model loaders were looked for. Person Shooters in DirectX 9 In general in the game industry, the formats are proprietary, so usually there is no access to this type of information. Introduction Getting started Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal .map animation player were found in Internet. Both of them were programmed in format and visibility OpenGL, so there was no problem to use the data structures generated by test them, but the rendering process in DirectX had to be programmed. func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 10. Programming In an attempt to know in depth the performance of the current FPS games, techniques for First level, mesh and geometric model loaders were looked for. Person Shooters in DirectX 9 In general in the game industry, the formats are proprietary, so usually there is no access to this type of information. Introduction Getting started Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal .map animation player were found in Internet. Both of them were programmed in format and visibility OpenGL, so there was no problem to use the data structures generated by test them, but the rendering process in DirectX had to be programmed. func plat meshes A bit on The level viewer works with .map format, was developed by Miguel Angel materials Pastor, aka Garrofi. His old homepage is all that can be found today. If you Parallax mapping want the source code of the level viewer, contact me at with aca_1983_@hotmail.com and i will send it to you, as there are no active links multiple point lights for download. The mesh viewer and animator player works with .md5 format Bibliography (md5mesh for meshes and md5anim for animations), and can be downloaded here.
  • 11. Programming In an attempt to know in depth the performance of the current FPS games, techniques for First level, mesh and geometric model loaders were looked for. Person Shooters in DirectX 9 In general in the game industry, the formats are proprietary, so usually there is no access to this type of information. Introduction Getting started Luckily, a Doom3 level viewer and a Doom 3 model viewer and skeletal .map animation player were found in Internet. Both of them were programmed in format and visibility OpenGL, so there was no problem to use the data structures generated by test them, but the rendering process in DirectX had to be programmed. func plat meshes A bit on The level viewer works with .map format, was developed by Miguel Angel materials Pastor, aka Garrofi. His old homepage is all that can be found today. If you Parallax mapping want the source code of the level viewer, contact me at with aca_1983_@hotmail.com and i will send it to you, as there are no active links multiple point lights for download. The mesh viewer and animator player works with .md5 format Bibliography (md5mesh for meshes and md5anim for animations), and can be downloaded here. Information about .map file format and .md5 file format can be read here and here respectively.
  • 12. Getting started Programming techniques Doom 3 was programmed in OpenGL, so a rendering process in DirectX for First Person required some changes, like texture coordinates, which are different in each Shooters in DirectX 9 API, or the coordinate systems used. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 13. Getting started Programming techniques Doom 3 was programmed in OpenGL, so a rendering process in DirectX for First Person required some changes, like texture coordinates, which are different in each Shooters in DirectX 9 API, or the coordinate systems used. Introduction Starting from an empty demo from the DirectX 9 SDK, the meshes of the Getting models where correctly rendered through index buffers and texturized. started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 14. Getting started Programming techniques Doom 3 was programmed in OpenGL, so a rendering process in DirectX for First Person required some changes, like texture coordinates, which are different in each Shooters in DirectX 9 API, or the coordinate systems used. Introduction Starting from an empty demo from the DirectX 9 SDK, the meshes of the Getting models where correctly rendered through index buffers and texturized. started .map format and These meshes are very optimized, for example, weapon meshes exclude those visibility test polygons from the mesh that never are viewed: func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 15. Programming techniques for First Person md5 meshes include the weapons carried by the player, so a first person Shooters in DirectX 9 shooter needs to render correctly those meshes when the camera moves. The problem was to make these meshes rotate correctly: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 16. Programming techniques for First Person md5 meshes include the weapons carried by the player, so a first person Shooters in DirectX 9 shooter needs to render correctly those meshes when the camera moves. The problem was to make these meshes rotate correctly: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 17. Programming techniques for First Person md5 meshes include the weapons carried by the player, so a first person Shooters in DirectX 9 shooter needs to render correctly those meshes when the camera moves. The problem was to make these meshes rotate correctly: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights The solution was to decompose the view matrix in its scaling, rotation and Bibliography translation factors when rendering each frame. The rotation factor, given by a quaternion, was then used to rotate correctly the weapon mesh and therefore give the appearance that the weapon follows the camera.
  • 18. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 19. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes Also a head up display was made, enabling alpha blending and disabling depth A bit on testing in order to keep the HUD visible even if the camera walks through a materials mesh. The number textures were taken from the Doom 3 textures, while some Parallax mapping simple symbols were made with Photoshop: with multiple point lights Bibliography
  • 20. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes Also a head up display was made, enabling alpha blending and disabling depth A bit on testing in order to keep the HUD visible even if the camera walks through a materials mesh. The number textures were taken from the Doom 3 textures, while some Parallax mapping simple symbols were made with Photoshop: with multiple point lights Bibliography
  • 21. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 22. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax In FPS games, weapons have some typical animations associated: firing, mapping reloading, idle, raise, lower... For the case of the shotgun in Doom 3, the with multiple animations available are the following: point lights empty.md5anim, fire1.md5anim, fire2.md5anim, fire3.md5anim, Bibliography idle.md5anim, lower.md5anim, raise.md5anim, reload_end.md5anim, reload_loop.md5anim, reload_loop2.md5anim, reload_loop3.md5anim, and reload_start.md5anim.
  • 23. Programming techniques for First Person If a realistic behaviour is wanted, a logical coordination of the animations is Shooters in DirectX 9 needed, so for the case of the shotgun, the first step is to play the raise animation, and when it ends, play the idle animation until player presses the Introduction reload or fire buttons, playing the corresponding animations and using Getting randomness if more than one animation is available for the current action, and started taking into account the ammo. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 24. Programming techniques for First Person If a realistic behaviour is wanted, a logical coordination of the animations is Shooters in DirectX 9 needed, so for the case of the shotgun, the first step is to play the raise animation, and when it ends, play the idle animation until player presses the Introduction reload or fire buttons, playing the corresponding animations and using Getting randomness if more than one animation is available for the current action, and started taking into account the ammo. .map format and visibility test The fire effect in the barrel of the weapon is achieved using a texture like the func plat following: meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 25. Programming techniques for First Person If a realistic behaviour is wanted, a logical coordination of the animations is Shooters in DirectX 9 needed, so for the case of the shotgun, the first step is to play the raise animation, and when it ends, play the idle animation until player presses the Introduction reload or fire buttons, playing the corresponding animations and using Getting randomness if more than one animation is available for the current action, and started taking into account the ammo. .map format and visibility test The fire effect in the barrel of the weapon is achieved using a texture like the func plat following: meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 26. Programming techniques for First Person If a realistic behaviour is wanted, a logical coordination of the animations is Shooters in DirectX 9 needed, so for the case of the shotgun, the first step is to play the raise animation, and when it ends, play the idle animation until player presses the Introduction reload or fire buttons, playing the corresponding animations and using Getting randomness if more than one animation is available for the current action, and started taking into account the ammo. .map format and visibility test The fire effect in the barrel of the weapon is achieved using a texture like the func plat following: meshes A bit on materials Parallax mapping with multiple point lights This texture consists in a series of sprites that must be shown correctly, Bibliography averaging the number of frames of the fire animation and showing the appropriate portion of sprite in the correct interval. The sprites are displayed in a plane mesh available in every weapon:
  • 27. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 28. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 29. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map Doom 3 levels consist in four file formats: format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 30. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map Doom 3 levels consist in four file formats: format and visibility The MAP file, an ASCII text file with all the static geometry and entities, test such as lights, patches (Bezier surfaces), brushes (simple geometric func plat meshes meshes) and the location of complex meshes whose geometry is loaded A bit on from files in a more general format (LWO for example). materials Parallax mapping with multiple point lights Bibliography
  • 31. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map Doom 3 levels consist in four file formats: format and visibility The MAP file, an ASCII text file with all the static geometry and entities, test such as lights, patches (Bezier surfaces), brushes (simple geometric func plat meshes meshes) and the location of complex meshes whose geometry is loaded A bit on from files in a more general format (LWO for example). materials Parallax The CM file, which stores the collision model data. mapping with multiple point lights Bibliography
  • 32. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map Doom 3 levels consist in four file formats: format and visibility The MAP file, an ASCII text file with all the static geometry and entities, test such as lights, patches (Bezier surfaces), brushes (simple geometric func plat meshes meshes) and the location of complex meshes whose geometry is loaded A bit on from files in a more general format (LWO for example). materials Parallax The CM file, which stores the collision model data. mapping with The PROC file, with all the preprocessed geometry in the map, portal multiple point lights information (Doom 3 operates with BSP-trees) and pre-calculated Bibliography shadow volumes (for static lights in static geometry).
  • 33. .map format and visibility test Programming techniques for First Person Shooters in The Doom 3 level viewer developed by Miguel Angel Pastor in OpenGL loads DirectX 9 most of the objects and entities of the level. Consists of more than 12000 lines of source code, and generates a data structure somewhat complex, as the Introduction amount and diversity of data is high. Getting started .map Doom 3 levels consist in four file formats: format and visibility The MAP file, an ASCII text file with all the static geometry and entities, test such as lights, patches (Bezier surfaces), brushes (simple geometric func plat meshes meshes) and the location of complex meshes whose geometry is loaded A bit on from files in a more general format (LWO for example). materials Parallax The CM file, which stores the collision model data. mapping with The PROC file, with all the preprocessed geometry in the map, portal multiple point lights information (Doom 3 operates with BSP-trees) and pre-calculated Bibliography shadow volumes (for static lights in static geometry). The AAS files, used by the AI to move the monsters in the scenario.
  • 34. Developing an efficient visibility test Programming techniques Once all the level geometry is loaded, and in order to optimize performance, a for First criteria must be followed to know what meshes must be rendered (among Person Shooters in those visible for the camera, i.e., inside the view frustum), and what must not. DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 35. Developing an efficient visibility test Programming techniques Once all the level geometry is loaded, and in order to optimize performance, a for First criteria must be followed to know what meshes must be rendered (among Person Shooters in those visible for the camera, i.e., inside the view frustum), and what must not. DirectX 9 Doom 3 levels use the BSP-tree system which divides a space into convex Introduction sets. Each convex set is called in this case an area, and two areas are Getting started connected through an IAP or Inter Area Portal. An example of the IAPs .map present in a Doom 3 level can be seen below: format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 36. Developing an efficient visibility test Programming techniques Once all the level geometry is loaded, and in order to optimize performance, a for First criteria must be followed to know what meshes must be rendered (among Person Shooters in those visible for the camera, i.e., inside the view frustum), and what must not. DirectX 9 Doom 3 levels use the BSP-tree system which divides a space into convex Introduction sets. Each convex set is called in this case an area, and two areas are Getting started connected through an IAP or Inter Area Portal. An example of the IAPs .map present in a Doom 3 level can be seen below: format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 37. Programming techniques for First Person Shooters in Those IAP (seen from above) have different sizes and not always consist of DirectX 9 four vertices. Thinking of IAPs as if they were windows, candidate meshes to be rendered will be those in the areas whose IAPs can be seen from the Introduction camera position and orientation. Also, BSP-trees allow to determine easily Getting which area a given point belongs to, so finding the area in which the camera is started located is simple. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 38. Programming techniques for First Person Shooters in Those IAP (seen from above) have different sizes and not always consist of DirectX 9 four vertices. Thinking of IAPs as if they were windows, candidate meshes to be rendered will be those in the areas whose IAPs can be seen from the Introduction camera position and orientation. Also, BSP-trees allow to determine easily Getting which area a given point belongs to, so finding the area in which the camera is started located is simple. .map format and visibility test The faster the method, the better the performance, because the visibility test func plat must be done every frame before the rendering process. There are several meshes ways to test what surfaces are visible in a scenario based on BSP-trees, A bit on materials currently there are several efficient methods, but new ways can be thought of? Parallax mapping with multiple point lights Bibliography
  • 39. Programming techniques for First Person Shooters in Those IAP (seen from above) have different sizes and not always consist of DirectX 9 four vertices. Thinking of IAPs as if they were windows, candidate meshes to be rendered will be those in the areas whose IAPs can be seen from the Introduction camera position and orientation. Also, BSP-trees allow to determine easily Getting which area a given point belongs to, so finding the area in which the camera is started located is simple. .map format and visibility test The faster the method, the better the performance, because the visibility test func plat must be done every frame before the rendering process. There are several meshes ways to test what surfaces are visible in a scenario based on BSP-trees, A bit on materials currently there are several efficient methods, but new ways can be thought of? Parallax mapping with The main task is to determine which IAPs of the current area are visible from multiple point lights the position and orientation of the camera, the meshes in those areas are the Bibliography candidate meshes to be rendered. The hardware technique occlusion culling can be used (a detailed explanation can be found here), in oder to know what IAPs are visible.
  • 40. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 41. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 42. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 43. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Render again the mesh to the small buffer (or bounding box). Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 44. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Render again the mesh to the small buffer (or bounding box). Finish the query Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 45. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Render again the mesh to the small buffer (or bounding box). Finish the query Getting started Retrieve information from the test: if the number of visible pixels is greater .map than cero, the mesh is visible from the camera position and orientation. format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 46. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Render again the mesh to the small buffer (or bounding box). Finish the query Getting started Retrieve information from the test: if the number of visible pixels is greater .map than cero, the mesh is visible from the camera position and orientation. format and visibility test The following is an example of the method. On the left several IAPs can be func plat seen in green color. On the right, the content of the small buffer after meshes performing the visibility test to one of the IAPs in the left: A bit on materials Parallax mapping with multiple point lights Bibliography
  • 47. Programming The concept is very simple: techniques for First Render to a small buffer the meshes being tested (or a bunding box for Person Shooters in performance). DirectX 9 For each mesh: Start the query. Introduction Render again the mesh to the small buffer (or bounding box). Finish the query Getting started Retrieve information from the test: if the number of visible pixels is greater .map than cero, the mesh is visible from the camera position and orientation. format and visibility test The following is an example of the method. On the left several IAPs can be func plat seen in green color. On the right, the content of the small buffer after meshes performing the visibility test to one of the IAPs in the left: A bit on materials Parallax mapping with multiple point lights Bibliography
  • 48. Programming This way, starting from the area in which lies the camera, all the visible IAPs techniques for First for that area can be known. But the IAPs from other areas are visible from Person Shooters in the current area sometimes, so the test must be refined, a way to improve the DirectX 9 test is described below. Introduction For each visible IAP of the current area, tested with the occlusion culling test Getting started (which will be called culled IAP), do the following: .map Consider all the IAPs in the area accessed through the current culled IAP, format and visibility which will be called secondary IAPs. test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 49. Programming This way, starting from the area in which lies the camera, all the visible IAPs techniques for First for that area can be known. But the IAPs from other areas are visible from Person Shooters in the current area sometimes, so the test must be refined, a way to improve the DirectX 9 test is described below. Introduction For each visible IAP of the current area, tested with the occlusion culling test Getting started (which will be called culled IAP), do the following: .map Consider all the IAPs in the area accessed through the current culled IAP, format and visibility which will be called secondary IAPs. test Trace straight lines from the corners and center of each secondary IAP to func plat meshes the camera, and check if any of the lines intersect with the culled IAP. A bit on materials Parallax mapping with multiple point lights Bibliography
  • 50. Programming This way, starting from the area in which lies the camera, all the visible IAPs techniques for First for that area can be known. But the IAPs from other areas are visible from Person Shooters in the current area sometimes, so the test must be refined, a way to improve the DirectX 9 test is described below. Introduction For each visible IAP of the current area, tested with the occlusion culling test Getting started (which will be called culled IAP), do the following: .map Consider all the IAPs in the area accessed through the current culled IAP, format and visibility which will be called secondary IAPs. test Trace straight lines from the corners and center of each secondary IAP to func plat meshes the camera, and check if any of the lines intersect with the culled IAP. A bit on If there is at least a line verifying the condition, then that secondary IAP materials is visible through the current culled IAP. The next image shows a scheme: Parallax mapping with multiple point lights Bibliography
  • 51. Programming This way, starting from the area in which lies the camera, all the visible IAPs techniques for First for that area can be known. But the IAPs from other areas are visible from Person Shooters in the current area sometimes, so the test must be refined, a way to improve the DirectX 9 test is described below. Introduction For each visible IAP of the current area, tested with the occlusion culling test Getting started (which will be called culled IAP), do the following: .map Consider all the IAPs in the area accessed through the current culled IAP, format and visibility which will be called secondary IAPs. test Trace straight lines from the corners and center of each secondary IAP to func plat meshes the camera, and check if any of the lines intersect with the culled IAP. A bit on If there is at least a line verifying the condition, then that secondary IAP materials is visible through the current culled IAP. The next image shows a scheme: Parallax mapping with multiple point lights Bibliography
  • 52. Programming techniques for First Person Shooters in DirectX 9 Introduction Each time an IAP turns out to be visible, its IAP path is saved, as this Getting process iterates with tertiary and more distant IAPs. When making a started tertiary IAP test, for example, the straight lines from the corners and .map format and center of the IAP must intersect with its corresponding secondary and visibility test culled IAPs. func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 53. Programming techniques for First Person Shooters in DirectX 9 Introduction Each time an IAP turns out to be visible, its IAP path is saved, as this Getting process iterates with tertiary and more distant IAPs. When making a started tertiary IAP test, for example, the straight lines from the corners and .map format and center of the IAP must intersect with its corresponding secondary and visibility test culled IAPs. func plat meshes The test goes on with quaternary and more distant IAPs (whenever there A bit on materials are remaining tests). At the end, there is a list of areas which are visible Parallax from the current camera position and orientation, so the meshes present mapping with in those areas are the candidates to be rendered. multiple point lights Bibliography
  • 54. Programming techniques for First Person Now its time to test the visibility of each mesh in the visible areas. The test is Shooters in DirectX 9 slightly different, as meshes are tridimensional objects: for a given area and a given mesh in that area, straight lines from each corner and the center of the Introduction bounding box of the mesh are traced to the camera. Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 55. Programming techniques for First Person Now its time to test the visibility of each mesh in the visible areas. The test is Shooters in DirectX 9 slightly different, as meshes are tridimensional objects: for a given area and a given mesh in that area, straight lines from each corner and the center of the Introduction bounding box of the mesh are traced to the camera. Getting started If any of these lines intersect with all the IAPs of the corresponding IAP path .map format and for the area in which the mesh lies, then that mesh is visible. visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 56. Programming techniques for First Person Now its time to test the visibility of each mesh in the visible areas. The test is Shooters in DirectX 9 slightly different, as meshes are tridimensional objects: for a given area and a given mesh in that area, straight lines from each corner and the center of the Introduction bounding box of the mesh are traced to the camera. Getting started If any of these lines intersect with all the IAPs of the corresponding IAP path .map format and for the area in which the mesh lies, then that mesh is visible. visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 57. Programming techniques Each time a mesh passes the test, is added to a vector of meshes. Once the for First Person test ends, the vector is sorted by the depth of the z coordinate of the Shooters in DirectX 9 bounding box. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 58. Programming techniques Each time a mesh passes the test, is added to a vector of meshes. Once the for First Person test ends, the vector is sorted by the depth of the z coordinate of the Shooters in DirectX 9 bounding box. Introduction This method can be improved: below, on the left, an IAP can be seen in dark Getting brown. Depending on the form of the bounding boxes of the meshes being started tested, the visibility test can fail, as can be seen in the image on the right. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 59. Programming techniques Each time a mesh passes the test, is added to a vector of meshes. Once the for First Person test ends, the vector is sorted by the depth of the z coordinate of the Shooters in DirectX 9 bounding box. Introduction This method can be improved: below, on the left, an IAP can be seen in dark Getting brown. Depending on the form of the bounding boxes of the meshes being started tested, the visibility test can fail, as can be seen in the image on the right. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 60. Programming A way to fix this is to add a small error bound, to mark as visible those techniques for First meshes which don’t pass the test for a little. Now the same mesh of the Person Shooters in previous image becomes visible. Small spheres corresponding with the corners DirectX 9 and the center point are rendered, giving an idea of the geometry of this type of simple meshes: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 61. Programming A way to fix this is to add a small error bound, to mark as visible those techniques for First meshes which don’t pass the test for a little. Now the same mesh of the Person Shooters in previous image becomes visible. Small spheres corresponding with the corners DirectX 9 and the center point are rendered, giving an idea of the geometry of this type of simple meshes: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 62. Programming Another improvement was introduced by considering the camera as a techniques for First tridimensional object: the camera position is a single point, but the camera Person Shooters in itself constitutes an area, so the test lines were aimed to the corners and DirectX 9 center point of the camera. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 63. Programming Another improvement was introduced by considering the camera as a techniques for First tridimensional object: the camera position is a single point, but the camera Person Shooters in itself constitutes an area, so the test lines were aimed to the corners and DirectX 9 center point of the camera. Introduction This way, when the central point of the camera is in front of a wall, the visible Getting started meshes farther than the wall pass the visibility test. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 64. Programming Another improvement was introduced by considering the camera as a techniques for First tridimensional object: the camera position is a single point, but the camera Person Shooters in itself constitutes an area, so the test lines were aimed to the corners and DirectX 9 center point of the camera. Introduction This way, when the central point of the camera is in front of a wall, the visible Getting started meshes farther than the wall pass the visibility test. .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 65. func plat meshes Programming techniques Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear. for First Person Some are complex meshes which must be loaded through an external file in Shooters in DirectX 9 .LWO or .ASE format, and others are the platforms and mobile meshes: elevators, doors... Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 66. func plat meshes Programming techniques Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear. for First Person Some are complex meshes which must be loaded through an external file in Shooters in DirectX 9 .LWO or .ASE format, and others are the platforms and mobile meshes: elevators, doors... Introduction Getting These meshes don’t belong to a particular area, so a test to find out which started areas belong had to be done, and in the visibility test, test each of these .map surfaces only once. The results for non-specific-area meshes were satisfactory: format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 67. func plat meshes Programming techniques Some meshes in the Doom 3 level viewer in OpenGL clearly did not appear. for First Person Some are complex meshes which must be loaded through an external file in Shooters in DirectX 9 .LWO or .ASE format, and others are the platforms and mobile meshes: elevators, doors... Introduction Getting These meshes don’t belong to a particular area, so a test to find out which started areas belong had to be done, and in the visibility test, test each of these .map surfaces only once. The results for non-specific-area meshes were satisfactory: format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 68. A bit on materials Programming techniques for First Person Shooters in DirectX 9 Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of this materials is built with specific keywords, which are detailed here and here. Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 69. A bit on materials Programming techniques for First Person Shooters in DirectX 9 Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of this materials is built with specific keywords, which are detailed here and here. Introduction Getting started In order to perform some per-pixel effects, height, normal and specular maps .map are needed for each mesh, besides the traditional diffuse map. Doom 3 format and visibility incorporates this textures, specified for each mesh in its definition. test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 70. A bit on materials Programming techniques for First Person Shooters in DirectX 9 Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of this materials is built with specific keywords, which are detailed here and here. Introduction Getting started In order to perform some per-pixel effects, height, normal and specular maps .map are needed for each mesh, besides the traditional diffuse map. Doom 3 format and visibility incorporates this textures, specified for each mesh in its definition. test func plat meshes By parsing all the .mtr files (Doom 3 uses more than 2600 different A bit on materials), the correct textures can be assigned to each mesh, although only materials simple per-pixel effects were made, like specular and parallax mapping or Parallax per-pixel lighting (due to lack of time). mapping with multiple point lights Bibliography
  • 71. A bit on materials Programming techniques for First Person Shooters in DirectX 9 Doom 3 displays a wide variety of materials, defined by the .mtr files. Each of this materials is built with specific keywords, which are detailed here and here. Introduction Getting started In order to perform some per-pixel effects, height, normal and specular maps .map are needed for each mesh, besides the traditional diffuse map. Doom 3 format and visibility incorporates this textures, specified for each mesh in its definition. test func plat meshes By parsing all the .mtr files (Doom 3 uses more than 2600 different A bit on materials), the correct textures can be assigned to each mesh, although only materials simple per-pixel effects were made, like specular and parallax mapping or Parallax per-pixel lighting (due to lack of time). mapping with multiple point lights Textures were loaded from a Zip file, an article in Gamedev explains how to do Bibliography this (can be read here).
  • 72. A bit on materials Programming techniques for First Person Shooters in DirectX 9 The next image shows on the left some meshes. The same meshes, with standard per-pixel lighting, are shown on the right (point lights are described Introduction as entities of type light in the file .map, with color and radius assigned): Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 73. A bit on materials Programming techniques for First Person Shooters in DirectX 9 The next image shows on the left some meshes. The same meshes, with standard per-pixel lighting, are shown on the right (point lights are described Introduction as entities of type light in the file .map, with color and radius assigned): Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 74. Parallax mapping with multiple point lights Programming techniques for First Person Shooters in DirectX 9 Parallax mapping produces a great effect of realism, and its computational cost is not exorbitant. The effect developed is based on the Parallax mapping Introduction demo from this web, which had in the past didactic material on DirectX Getting started (email me at aca_1983_@hotmail.com and i will send this demo to you). .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 75. Parallax mapping with multiple point lights Programming techniques for First Person Shooters in DirectX 9 Parallax mapping produces a great effect of realism, and its computational cost is not exorbitant. The effect developed is based on the Parallax mapping Introduction demo from this web, which had in the past didactic material on DirectX Getting started (email me at aca_1983_@hotmail.com and i will send this demo to you). .map format and visibility This application was programmed in 2006, when the most extended Shader test Model was the 2.0. This Shader Model had a limit of 96 registers and 64 func plat meshes instructions, so the limit for the effect was three passes (for three different A bit on point lights). materials Parallax mapping with multiple point lights Bibliography
  • 76. Parallax mapping with multiple point lights Programming techniques for First Person Shooters in DirectX 9 Parallax mapping produces a great effect of realism, and its computational cost is not exorbitant. The effect developed is based on the Parallax mapping Introduction demo from this web, which had in the past didactic material on DirectX Getting started (email me at aca_1983_@hotmail.com and i will send this demo to you). .map format and visibility This application was programmed in 2006, when the most extended Shader test Model was the 2.0. This Shader Model had a limit of 96 registers and 64 func plat meshes instructions, so the limit for the effect was three passes (for three different A bit on point lights). materials Parallax mapping If more than three point lights light a mesh, is neccessary to activate blending with (which means a drop in performance) and repeat the effect until all the multiple point lights contributions on all the lights have been calculated. Bibliography
  • 77. Programming techniques for First Person Shooters in The following image shows the parallax mapping effect, with a maximum of DirectX 9 three point lights for each mesh on the left, and for more than three point lights in the right: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 78. Programming techniques for First Person Shooters in The following image shows the parallax mapping effect, with a maximum of DirectX 9 three point lights for each mesh on the left, and for more than three point lights in the right: Introduction Getting started .map format and visibility test func plat meshes A bit on materials Parallax mapping with multiple point lights Bibliography
  • 79. Programming techniques for First Person Bibliography Shooters in DirectX 9 Ultimate Game Programming Allen Sherrod. http://www.ultimategameprogramming.com, September 2006. Introduction Getting GameDev.net Developer Community. started http://www.gamedev.net, September 2006. .map format and visibility Md5 mesh viewer in OpenGL David Henry. test http://tfc.duke.free.fr, September 2006. func plat meshes Occlusion Culling Using DirectX 9 Dustin Franklin. A bit on materials http://www.gamedev.net, September 2006. Parallax mapping MAP file format. with multiple http://www.modwiki.net, September 2006. point lights Bibliography MD5 file format. http://www.modwiki.net, September 2006. Loading a Texture From a Zip File in DirectX 9 Greg Stewart. http://www.gamedev.net, September 2006.
  • 80. Programming techniques for First Person Shooters in DirectX 9 Introduction Getting started Global material keywords. .map format and http://www.modwiki.net, September 2006. visibility test Game Tutorials. func plat meshes http://www.gametutorials.com, September 2006. A bit on materials Parallax mapping with multiple point lights Bibliography