C++

DX11 Render Engine

Multiple Shaders

The render engine comes included with multiple types of shaders already built-in. Each shader can be easily toggled between filled and wireframes modes. The included shaders that support lighting use Phong-based shading for a balance between speed and realism.

The pipeline supports updating and rendering different graphic objects using different shaders.

N-Light Support

As an experiment, I wanted to support a dynamic amount of lights with my forward rendering shaders. Officially, this support is not possible in DirectX11, as this would require bottomless arrays in the constant buffers (a feature that is available in DirectX12).

Using "controlled" array indexing out of bounds, I was able to support this feature (the amount of lights would need to be defined during instantiation of a shader object). In one constant buffer, the number of directional/spot/point lights would be defined, which would match the amount of memory requested from the GPU during construction. For each type of light, a different constant buffer was defined in the HSLSL shader with a length of two. By making these constant buffers have a length of two, this forced the HLSL compiler to treat the indexing as an array.

Within the actual pixel shader code we have our usual forward rendering loops for each light. The loop iterator would reference the light count variables in the first constant buffer. This forced the compiler to not be able to un-roll the loop during compilation (requiring it to actually check the value of the shader constant). Technically, these loops are indexing out of bounds (if the light count is more than two), but since I actually request the correct amount of memory, we are still indexing into our light data. Using these slightly clever tricks, I was able to create a forward rendering shader supporting N-count of lights.

Multi-Mesh Models

The render engine supports the ability to import models that contain more than one mesh using the engine's mesh separator. Also supported is the ability to set material/color/texture on a per-mesh basis, as well. This allows for more complicated models that may use multiple textures, or meshes that appear to be made of different material.

Example Scene

Tech Demo