A Game scene implemented in DirectX 11.
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.
Uses fixed-axis rotation.
Program file can be downloaded here.
Requirements: DirectX 11 supported graphics card, Windows 7/8/8.1/10/11, Visual C++ Redistributable Packages for Visual Studio 2013(x86).
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.