Home

Awesome

Volume Tiled Forward Shading

The project uses GitHub's Large File Storage (LFS). Make sure you install git lfs before cloning this repository (requires git >= 1.8.2).

git lfs install

If you cloned the repository before installing LFS, pull the files again after FLS is installed.

git lfs pull

See Git LFS Tutorial for more information on using git-lfs.

Table of Contents

Introduction

This project demonstrates the following rendering techniques:

To compile and run the game, see the Compiling section below.

Prerequisite

The project comes with a precompiled (release) build executable that can be used to test the project. The project was built using the Windows 10 SDK (10.0.16299.0). If you just want to run the demo without first installing Visual Studio, the Microsoft Visual C++ redistributable must be installed first.

The Visual C++ redistributable installer can be found in the Redist\MSVC\<version> folder.

CMake

The project and solution files are generated using the CMake build configuration system. The following generators should work to generate the solution and project files:

The Ninja generator may also work but I've experienced some issues with precompiled headers when using the Ninja generator.

Refer to the GenerateProjectFiles.bat to generate the project files depending on the version of Visual Studio that is currently installed.

Visual Studio

Although the project uses CMake to define the project settings, Visual Studio 2017 (15.4) was used to compile the project. It was tested with Visual Studio Enterprise but there is no reason it shouldn't work with Visual Studio Community.

Windows 10 SDK

The project has been compiled and tested using the Windows 10 SDK (10.0.16299.0). The latest Windows 10 SDK can be downloaded from the Windows 10 SDK website here.

Running the Demo

Volume Tiled Forward Shading

Before running the demo, decompress the included assets by executing the DecompressAssets.bat batch file in the root folder. The model files assets have been compressed using 7-zip (included in the Tools\7Zip folder) to reduce the download time. The uncompressed assets require 1.5 GB of disk space.

The demo must be run from the bin folder. To run the pre-compiled release build, exectute the Run_Release.bat. This batch file will run the demo from the correct folder to ensure that the default configuration file can be loaded. By default, the DefaultConfiguration.3dgep configuration file will be loaded which imports the Crytek Sponza Atrium scene.

To test with different configuration settings, open the Conf folder and run the RegisterFileType_Win10_Rel_x64.bat batch file to register a file handler for the .3dgep file extension. After registering the file handler, you should be able to double-click on any .3dgep configuration file to run the demo using that configuration. Use the UnregisterFileType_Win10_Rel_x64.bat batch file to remove the file handler.

For a complete explanation about the format of the configuration files, see the Configuration section below.

Controls

The demo uses the following keyboard keys:

KeyAction
ESCExits the application.
Alt+F4Exits the application.
QPan the camera down (along the camera's local Y axis).
EPan the camera up (along the camera's local Y axis).
WPan the camera forward (along the camera's local Z axis).
APan the camera left (along the camera's local X axis).
SPan the camera backward (along the camera's local Z axis).
DPan the camera right (along the camera's local X axis).
FMoves the camera (Focus) to the currently selected light.
0Move the camera to the world origin.
RResets the camera to the position specified in the configuration file.
ShiftHold shift while pressing one of the other movement keys to move the camera faster.
MToggle Muilti-Sample Anti Aliasing (MSAA)
LToggle rendering of debug light volumes.
VToggle V-sync (turn this on if you experience screen tearing).
SpaceToggle animation of the lights in the scene.
1Render using Forward Rendering.
2Render using Tiled Forward Shading (Forward+).
3Render using Volume Tiled Forward Shading.
4Render using Volume Tiled Forward Shading with BVH.
Ctrl+1Toggle Statistics UI.
Ctrl+2Toggle Profiler UI.
Ctrl+3Toggle Generate Lights UI.
Ctrl+4Toggle Light Editor UI.
Ctrl+5Toggle Options UI

Tiled Forward Shading

While viewing the Tiled Forward Shading (Forward+) rendering technique, the following actions are available.

KeyAction
F1Toggle display of the tile heatmap.

Volume Tiled Forward Shading

While viewing the Volume Tiled Forward Shading rendering technique, the following actions are available.

KeyAction
F1Toggle display of volume tile heatmap.
F2Toggle display of debug volume tiles.
Shift+FToggle the update of the volume tiles. Makes it possible to observe the volume tiles while the debug volume tiles are rendered.

Camera

The camera for this demo uses a First-Person Shoter style controller. To rotate the view, click and drag on the screen using the left-mouse button (LMB). Use the W, A, S, D, to move the camera forward, left, backward, and right (respectively). Use the Q, and E keys to move the camera up and down in the camera's local space. Hold the Shift key to move the camera faster. LMB clicking and dragging on a UI window will move that window instead of rotating the camera.

XBox 360, XBox One Controller

The demo supports XInput controllers (XBox 360, XBox One, or any similar input device).

Buttons

The demo handles the following button events from the controller.

LS - Left analog stick. (Also a button).

RS - Right analog stick (Also a button).

RB - Right bumper.

LB - Left bumper.

LT - Left trigger.

RT - Right trigger.

ButtonAction
LSToggle faster translation.
RSToggle raster rotation.
LTPan the camera down.
RTPan the camera up.

Axes

The demo handles the following axis events from the controller.

AxisAction
LSPan camera.
RSRotate camera.

Compiling

To generate the Visual Studio solution and project files, run the GenerateProjectFiles.bat file in the root of the repository. This will generate the project files in the following folders depending on which version of Visual Studio was detected:

Visual Studio VersionFolder
2017 (15.0)Build_VS15
2014 (14.0)Build_VS14

The project comes with CMake 3.9.0 executable so there is no need to download CMake if it is not installed or the installed version of CMake is earlier than 3.9.0. You may choose to generate the project files yourself if either you have a new version of CMake installed or you want to use a different generator (for example Ninja). I have experienced some issues using Ninja to generate the build files which is discussed in the Known Issues secion below.

Configuration

All of the configuration settings to run the demo are specified a configuration file. Configuration files are found in the Conf folder. The -c or --config command line option can be used to specify the configuration file to use when running the demo. Registering the file handler for the .3dgep file extension (as previously explained in the Running the Demo section above) should make it possible to simply double-click on the .3dgep configuration files to run that configuration in the demo.

The easiest way to create a new custom configuration file is to copy the DefaultConfiguration.3dgep file and edit the settings according to the table below.

Do not delete the DefaultConfiguration.3dgep file as this one is used if no configuration file is specified on the command-line when running the programing (for example, if the executable is launched by double-clicking on the .exe file in Windows Explorer).

The configuration files are XML documents that contain the following information:

PropertyTypeSetting
WindowWidthintThe width of the window's client area in pixels.
WindowHeightintThe height of the window's client area in pixels.
FullScreenintCurrently unsupported. Set to 0 for windows mode, or 1 for fullscreen mode.
SceneFileNamestringThe path to the model file to load. This path is expressed relative to the configuration file.
SceneScaleFactorfloatA scale factor to apply to the scene after loading.
CameraPositionfloat3A 3-component vector representing the initial 3D position of the camera.
CameraRotationfloat4A rotation quaternion representing the initial 3D rotation of the camera. No rotation is (0, 0, 0, 1)
NormalCameraSpeedfloatThe speed of the camera.
FastCameraSpeedfloatThe speed of the camera while the [SHIFT] key is pressed.
CameraPivotDistancefloatThe initial distance that the cameras rotation pivot point is placed in front of the camera.
PointLightsArrayThe point lights array should only be configured using the on-screen GUIs.
SpotLightsArrayThe spot lights array should only be configured using the on-screen GUIs.
DirectionalLightsArrayThe directional lights array should only be configured using the on-screen GUIs.
LightsMinBoundsfloat3The minimum bounds to generate lights.
LightsMaxBoundsfloat3The maximum bounds to generate lights.
MinSpotAnglefloatThe minimum spot light angle (in degrees) to use when generating spot lights.
MaxSpotAnglefloatThe maximum spot light angle (in degrees) to use when generating spot lights.
MinRangefloatThe minimum range of generated light sources.
MaxRangefloatThe maximum rnage of generated light sources.
NumPointLightsintThe number of point lights to randomly generate.
NumSpotLightsintThe number of spot lights to randomly generate.
NumDirectionalLightsintThe number of directional lights to randomly generate.

It should not be necessary to specify the light sources in the configuration file. In order to generate lights sources in the scene, use the Generate Lights GUI described in the next section.

Generate Lights GUI

The demo uses ImGUI to provide various user interfaces. In this section, the Generate Lights GUI is explained.

To open the Generate Lights GUI, press Ctrl+3 on the keyboard or select View > Generate Lights from the menu bar.

Generate Lights GUI

The following options are available in the Generate Lights GUI:

OptionTypeDescription
Num Point Lightsunsigned intThe number of point light sources to generate.
Num Spot Lightsunsigned intThe number of spot light sources to generate.
Num Directional Lightsunsigned intThen number of directional light sources to generate.
Normalize Point LightsbuttonCompute the number of point light sources to achieve an average light density of 1 light / unit<sup>3</sup> given the current bounds and light ranges.
Normalize Spot LightsbuttonCompute the number of spot light sources to achieve an average light density of 1 light / unit<sup>3</sup> given the current bounds and light ranges.
Min Boundsfloat3The minimum point of the bounding volume to generate the light sources.
Max Boundsfloat3The maximum point of the bounding volume to generate the light sources.
Normalize BoundsbuttonCompute the minimum and maximum bounds (assume [0, 0, 0] is the center of the bounding volume) to achieve an average light density of 1 light / unit<sup>3</sup> given the number of lights and max light range.
Min Spot AnglefloatThe minimum cone angle (degrees) to use when generating spot lights.
Max Spot AnglefloatThe maximum cone angle to use when generating spot lights.
Min RangefloatThe minimum light range to use when generating light sources (point and spot).
Max RangefloatThe maximum light range to use when generating light sources (point and spot).
Normalize Light RangesbuttonCompute the maximum light range to achieve an average light density of 1 light / unit<sup>3</sup> given the bounds volume and the number of light sources to generate. The minimum light range is set to 10% less than the maximum point range.
Generate LightsbuttonRandomly generate light sources in the scene.

Troubleshooting

This section describes troubleshooting tips if the demo does not run.

Website for more information: https://www.3dgep.com/volume-tiled-forward-shading/

Known Issues

FAQ

Contributors

This project is maintained by