In order to compare with the previous version of the program, the update is done in a manner that preserves the original algorithm and data structure. Updates that result in major changes in algorithm or data structure are not performed.
Since the Game Scene is not designed with C++11/14 features in the first place, after the scene is updated, performance only improves slightly.
However, the scene and program’s code still benefit from the new C++ features.
For example, the code structures in various parts of the project are cleaner.
Load time is reduced and data are handled in more efficient ways with the use of move and rvalue reference.
Function overhead is also reduced due to the use of lambda.
This experiment shows that the C++11/14 standard offers useful and powerful features for Game development and programming in general.
Features utilized: auto, decltype, uniform initialization and initializer list, new style function declaration, delete keyword, override identifier, nullptr, range-based for loop, right angle bracelet, strong typed enum, smart pointer, move and rvalue reference, lambda, and digit separator.
Floor utilizes normal mapping to make it appear to have more details.
Sky is implemented using a sky-dome primitive and a cube map texture.
Tower objects are rendered using instancing method. Each tower has its own transformation(rotation and translation) but all towers have the same scaling. Since the tower model has transparency parts on it, alpha clipping is utilized.
Bat object has skeletal animations implemented as a combined animation. Skeletal animation system is manually implemented and utilizes vertex blending and quaternion interpolation.
Tower and bat objects have back-face culling disabled when drawn since they have some parts that have to be visible even though they are back-facing.
Lighting is also implemented in this scene.
All the objects in the scene are shaded in a way like there are in sunlight.
Tower and bat objects are just normal models with only model textures, no normal map textures are provided. In this scene, the bat object appears to have specular highlights. This is because the bat model does not have normal map texture provided, as a result, averaged normal vectors from the model’s vertices are used instead.
Light source utilizes in the scene is a point light to demonstrate shadow. The light source can be moved around in the scene which will make shadows of the objects in the scene change position.
Shadows of the objects in the scene are implemented using dynamic shadow mapping which renders the scene from the perspective of the light source into shadow map(depth map) texture every frame. Any change of objects in the scene(like the bat’s animation) will result in its shadow being changed in real time. The intensity of shadows can also be changed, however, the shadow’s intensity is fixed in this program.
(Rendering and litting the scene from the perspective of light sources are part of volumetric lighting technique. Projective light maps can be utilized for this technique.)
Shadow map texture generated is used to render shadows of objects in the scene via projective texturing. PCF filtering is implemented for smoothing the edge of shadows rendered. Depth bias is also utilized when rendering the shadow map(depth map) to help fix shadow acne problem. (Shadow mapping in this scene can still be improved and shadow acne can still appear on some surfaces in the scene which becomes noticeable when zooming in).
Shadow map(depth map) texture generated can be viewed. Any change of objects in the scene will be reflected in the shadow map in real time. For showing shadow map texture as a greyscale image, re-linearization is needed for depth values in the shadow map texture since the original depth values from shadow map texture are non-linear values.
Camera systems are manually designed and implemented from scratch and can be switched between 3 modes.
First person shooter(FPS) mode. Camera mode like in FPS games. The bat character can be controlled in the same manner as in FPS games.
Third person shooter(TPS) mode. Camera mode like in TPS games. The character can be controlled in the same manner as in TPS games.
Third person(TP) mode. Camera mode like in third-person games. The camera can be moved around in the scene in this mode and has been designed in a way that prevents Gimbal lock. Camera focuses on the character. Moving the character forward will make the character move in the direction the camera is facing. Moving the character backward will make the character move toward the camera. In both cases, the camera will adjust itself according to the character’s position. Moving in the left or right direction will cause the character to move left or right in a circle, the camera will also adjust itself according to the character’s position. Moving the character diagonally forward or backward will cause the camera to adjust itself to the character’s position too. Notice that when the character turns around in this mode when moving around in the scene. It will always turn around from one orientation to another orientation using the shortest arc.
Collision detection is also implemented. Collision detection implemented is just a simple collision detection using AABB(Axis-Aligned Bounding Box). Collision detection in this program is meant to be a test feature and is not optimized in any way. Unintentional behavior can occur sometimes. Collision detection feature can be turned on and off to help ease unintentional behavior if it occurs. Camera collision is not implemented.
Gamepad is also supported. Gamepad’s type supported is X-Input gamepad type. The program will recognize the gamepad automatically when plugged in.
Control:
Press “p” on the keyboard to make the bat character perform animations.
Press “l” on the keyboard to toggle light source re-positioning mode on and off. In this mode, the light source can be moved around in the scene via holding left-click and drag the mouse.
Press “m” on the keyboard to toggle the rendering of shadow map on the screen. If turned on, the dynamic shadow map that is rendered every frame can be viewed as a minimap at the corner of the program’s screen.
Press “u” on the keyboard to toggle collision detection on and off.
The default camera mode is Third person mode.
The character’s orientation and position are consistent across all of the camera modes.
Press “1” on the keyboard to change the camera into First person shooter mode.
FPS camera mode:
Moving the mouse will change the direction the character is facing.
Press “w” on the keyboard to move the character forward.
Press “a” on the keyboard to move the character to the left.
Press “s” on the keyboard to move the character backward.
Press “d” on the keyboard to move the character to the right.
Moving character diagonally is also possible by pressing w and a/d or s and a/d at the same time.
Press “2” on the keyboard to change the camera into Third person shooter mode.
TPS camera mode:
Moving the mouse will change the direction the character is facing.
Press “w” on the keyboard to move the character forward.
Press “a” on the keyboard to move the character to the left.
Press “s” on the keyboard to move the character backward.
Press “d” on the keyboard to move the character to the right.
Moving character diagonally is also possible by pressing w and a/d or s and a/d at the same time.
Press “3” on the keyboard to change the camera into Third person mode.
TP camera mode:
Left-click anywhere in the scene then hold left-click and drag the mouse to move the camera around in the scene.
Press “w” on the keyboard to move the character in the direction the camera is facing.
Press “a” on the keyboard to move the character to the left of the direction the camera is facing.
Press “s” on the keyboard to move the character in the opposite direction of the direction the camera is facing.
Press “d” on the keyboard to move the character to the right of the direction the camera is facing.
Moving character diagonally is also possible by pressing w and a/d or s and a/d at the same time.
Using Gamepad:
Gamepad control is referenced based on the layout of the buttons of Xbox360 game controller and Xbox One game controller.
Moving the left analog stick up will give the same result as pressing “w” on the keyboard in any camera mode.
Moving the left analog stick left will give the same result as pressing “a” on the keyboard in any camera mode.
Moving the left analog stick down will give the same result as pressing “s” on the keyboard in any camera mode.
Moving the left analog stick right will give the same result as pressing “d” on the keyboard in any camera mode.
Moving the character diagonally is possible by moving the left analog stick diagonally.
Moving the right analog stick will give the same result as moving the mouse in First person shooter and Third person shooter camera mode and “hold left-click and drag the mouse” in Third person mode.
Press “B” button on the gamepad to make the bat character perform animations.
Press “A” button on the gamepad to toggle light source re-positioning mode on and off. In this mode, the light source can be moved around in the scene by moving the right analog stick.
Press “X” on the gamepad to toggle the rendering of shadow map on the screen.
Press “Y” on the gamepad to toggle collision detection on and off.
Press “RB” on the gamepad to change the camera into First person shooter mode.
Press “RT” on the gamepad to change the camera into Third person shooter mode.
Press “LT” on the gamepad to change the camera into Third person mode.
Platform: Windows
Programming Language: C/C++, HLSL
Resources: Sky cube map texture is from companion DVD of the book 3D Game Programming with DirectX 11 by Frank D. Luna, Mercury Learning.
Texture loading is implemented using DirectX TK library.
3D model loading is implemented using ASSIMP. ASSIMP loads 3D models and provides data loaded in its own format.
In order to make 3D model data loaded by ASSIMP easier to use, a wrapper for ASSIMP that parses data from ASSIMP’s format into a format that is easier to work with, handles model loading and animation processing has been manually created.
Gamepad’s input handling is implemented using DirectX TK library.
A Game scene with 3D models, skeletal animation, and mirror effect.
The bat model has skeletal animations that are created and embedded in the model as a combined animation.
Skeletal animation system is manually implemented and utilizes vertex blending and quaternion interpolation.
Tower model has alpha clipping implemented since it has transparent parts.
Mirror effect is implemented using stenciling.
The mirror in the scene has been designed as an ideal mirror, with no surface effects or distortion of the picture in the mirror.
Mirror’s surface can be modified by modulated with colors from textures to create surface effects.
Back-face culling is disabled for the bat model, tower model, and floor while enabled for the mirror and wall the mirror was on.
Uses fixed-axis rotation.
Control:
Left-click anywhere in the scene then hold left-click and drag the mouse to move the camera around in the scene.
Scroll up and down to zoom in and zoom out.
Press “p” on the keyboard to make the bat character perform animations.
Platform: Windows
Programming Language: C/C++, HLSL
Texture loading is implemented using DirectX TK library.
3D model loading is implemented using ASSIMP. ASSIMP loads 3D models and provides data loaded in its own format.
In order to make 3D models’ data loaded by ASSIMP easier to use, a wrapper for ASSIMP that parses data from ASSIMP’s format into a format that is easier to work with, handles model loading and animation processing has been manually created.
Another improvement can be added to Waves posts(here and here).
With lighting and normal mapping already implemented. The color of the waves can also be modified to make them look more like real water. The waves’ surface transparency property is then taken into account.
By having another surface beneath the waves and making the surface of the waves semi-transparent using transparency blending, a more realistic wave surface can be achieved.
Backface culling is disabled.
Uses fixed-axis rotation.
Control:
Left-click anywhere in the scene then hold left-click and drag the mouse to move the camera around in the scene.
Double-click to toggle between solid and wireframe mode.
Scroll up and down to zoom in and zoom out.
Platform: Windows
Programming Language: C/C++, HLSL
Resources: Normal map and height map textures(Normal vector values and height values are combined into the same texture) are from companion DVD of the book 3D Game Programming with DirectX 11 by Frank D. Luna, Mercury Learning.
Texture loading is implemented using DirectX TK library.
Waves from Waves post improved with lighting and normal mapping.
Details on the waves’ surface have been increased by implementing lighting and applying normal mapping on the waves.
Normal vector values are derived from normal map textures which also contain height values for the vertices of the waves that are used for the implementation of displacement mapping(Height mapping).
Light source utilized in the scene is directional light.
Backface culling is disabled.
Uses fixed-axis rotation.
Control:
Left-click anywhere in the scene then hold left-click and drag the mouse to move the camera around in the scene.
Double-click to toggle between solid and wireframe mode.
Scroll up and down to zoom in and zoom out.
Platform: Windows
Programming Language: C/C++, HLSL
Resources: Normal map and height map textures(normal vector values and height values are combined into the same texture) are from companion DVD of the book 3D Game Programming with DirectX 11 by Frank D. Luna, Mercury Learning.
Texture loading is implemented using DirectX TK library.