A 3d renderer engine built from scratch with DirectX11 and Win32
This renderer engine is a half-year-long personal project following ChiliTomatoNoodle's Tutorial. This document is a detailed review of the significant commits to this repository from the very beginning of the project.
Latest commits are shown first.
Implemented shadow map and Percentage Close Filtering (PCF) to the sponza scene. Shadow map technique was configured during model loading and controllable during the rendering. Users can specify which objects cast shadows and which receive. Applied shadow bias and PCF for better shadow performances.
Current render passes (implemented in GRAPHICS_RG_BlurOutlineRenderGraph.cpp):
- Generate shadow map
- Lambertian
- Outline mask (generate stencil buffer)
- Gauss blur (for outline effect)
- Camera wireframes and frustums
More detailed note about shadow mapping: GAMES 101 lecture note: shadow mapping.
Basic shadow mapping
Filename | Description |
---|---|
GRAPHICS_OBJ_ShadowCameraCBuffer.h | cpp |
|
GRAPHICS_OBJ_ShadowSampler.h | cpp |
|
ShadowTest_VS.hlsl | ShadowTest_PS.hlsl |
|
PlaceHolder.h | cpp |
|
Percentage Close Filtering
Filename | Description |
---|---|
_PShadow_Static.hlsli |
|
_PShadow_Dynamic.hlsli |
|
PShadow.hlsli |
|
Sloped-Scaled Shadow Bias
Filename | Description |
---|---|
GRAPHICS_OBJ_ShadowRasterizer.h | cpp |
|
Commit | Description |
---|---|
Basic Shadow Mapping |
|
Advanced Shadow Mapping |
|
Added depth sampling from any camera. This is the prerequisite for shadow maps.
Filename | Description |
---|---|
GRAPHICS_PASS_ShadowMappingPass.h |
|
GRAPHICS_OBJ_Channels.h | cpp |
|
Commit | Description |
---|---|
GRAPHICS_OBJ_DepthStencil.h | cpp |
|
Depth sampling |
|
Added supports for setting multiple cameras. This is a prerequisite for shadow mapping.
Filename | Description |
---|---|
GRAPHICS_PASS_WireframePass.h |
|
GRAPHICS_OBJ_CameraContainer.h | cpp |
|
GRAPHICS_OBJ_Projection.h | cpp |
|
GRAPHICS_OBJ_Frustum.h | cpp |
|
GRAPHICS_OBJ_CameraIndicator.h | cpp |
|
Commit | Description |
---|---|
Reorganized shader files, fixed bindable pool bug when resolving inputlayout |
|
Multiple cameras |
|
A render graph (or frame graph) is a way of defining the rendering pipeline using self-contained nodes in an acyclic directed graph. Each node has a set of input and outputs, which link to other nodes or resources. When executed, the graph is traversed executing each node in turn. In the current version, every node represents a pass.
The render graph system takes in nodes (passes) with input/output and validates/links the nodes together. This system allows us to avoid hardcoding the render procedure, but configure it io a graph-like, more organized and automatic way.
To avoid name conflicts, the input and the output for each pass is named as sink (required input type for this pass) and source (output type from this pass).
After this update, the current render process (in App.cpp) is:
-
Engine Initialization(): Create a render graph, which initializes of all passes, creates and links all sinks/sources. Note that the sequenec of passes are specified by the order in a vector.
-
Engine Initialization(): Import models. The Material.cpp automatically assign pass type (by universal pass name strings like "lambertian") to the leaf meshes according to the resource setting.
-
Engine Start(): The model calls LinkTechniques(RenderGraph), passing the render graph all the way to the mesh leaves. When LinkTechniques() eventually hit the leaves, a leaf will notify its techniques and steps to get the real Pass reference from the render graph (previously just a name string assigned by Material.cpp).
-
Engine Update(): All models will call Submit() to notify all leaf -> Technique -> Step to submit a job (contains the drawable with recent updates like transforms) to the target pass (reference got from previous step).
-
Engine Update(): All the renderGraph.Execute() to render all passes and their jobs.
Filename | Description |
---|---|
GRAPHICS_RG_Sink.h | cpp | GRAPHICS_RG_Source.h | cpp |
|
GRAPHICS_RG_RenderGraph.h | cpp |
|
GRAPHICS_RG_BlurOutlineRenderGraph.h | cpp | GRAPHICS_RG_ScaleOutlineRenderGraph.h | cpp |
|
| GRAPHICS_PASS_RenderQueuePass.h | cpp | GRAPHICS_PASS_BindingPass.h | cpp | GRAPHICS_PASS_BufferClearPass.h | cpp | GRAPHICS_PASS_FullscreenPass.h | cpp | GRAPHICS_PASS_HorizontalBlurPass.h | cpp | GRAPHICS_PASS_VerticalBlurPass.h | cpp |
|
Commit | Description |
---|---|
Render Graph |
|
Applying blur effect to the pipeline output image. Due to the complex nature of applying outline effect in geometry space (model pivot not centered, mesh not contineous, cannot combine alpha channel, etc.), we now apply the outline effect to the screen space directly.
Filename | Description |
---|---|
GRAPHICS_OBJ_DepthStencil.h | cpp |
|
GRAPHICS_OBJ_GraphicsResource.h | cpp |
|
GRAPHICS_OBJ_RenderTarget.h | cpp |
|
GRAPHICS_OBJ_BlurPack.h | cpp |
|
Commit | Description |
---|---|
FullScreen Filters |
|
GRAPHICS_JOB_FrameCommander.h | cpp |
|
Separated Gauss Blur Effect |
|
This update extends the job system and allows automatic job detection by "probes" traverling in the model-hierarchy. The probe system has two major updates: 1) when hitting the leaf mesh, auto-gen job. 2) when hitting the leaf mesh, auto-gen controls in the UI menu.
Filename | Description |
---|---|
GRAPHICS_JOB_ModelProbe.h | cpp |
|
GRAPHICS_JOB_TechniqueProbe.h | cpp |
|
GRAPHICS_OBJ_Material.h | cpp |
|
Commit | Description |
---|---|
Basic probe system |
|
GRAPHICS_OBJ_Model.h | cpp | GRAPHICS_OBJ_Node.h | cpp |
|
GRAPHICS_OBJ_DynamicVertex.h | cpp |
|
UI controll for model nodes. |
|
In previous code, meshes like the sponza scene are configured and rendered as a whole, which does not support scene graph which allows modification on sub-meshes. To apply different render techniques to respective parts, we have to manually separate the meshes and hard code the render order for dependency concern. Job system provides handles to all sub-meshes for individual rendering jobs/steps by specified techniques.
The new mesh-hierarchy hence becomes Drawable -> Model (like the Sponza) -> Nodes (like a vase) -> Meshes (the vase drawable shared between all vases) -> Techniques (like the outline effect) -> Steps (the actual process to make the outline, which contains references to bindables and the mesh data). For each step, we register a job (contains ptr to mesh data and ptr to step/bindables). Rendering
Filename | Description |
---|---|
GRAPHICS_JOB_FrameCommander.h | cpp |
|
GRAPHICS_JOB_Technique.h | cpp |
|
GRAPHICS_JOB_Step.h | cpp |
|
GRAPHICS_JOB_Job.h | cpp |
|
GRAPHICS_JOB_Pass.h | cpp |
|
GRAPHICS_OBJ_NullPixelShader.h | cpp |
|
Commit and Files | Description |
---|---|
TestCube.h | cpp |
|
Job System |
|
A system that examines model resources and automatically configures render procedures. For example, configure a alpha tester shader when alpha channel texture detected. This system also provides handles to all shader constants for run-time modification.
Filename | Description |
---|---|
GRAPHICS_OBJ_DynamicConstant.h | cpp |
|
GRAPHICS_OBJ_LayoutPool.h | cpp |
|
GRAPHICS_OBJ_Stencil.h | cpp |
|
Commit | Description |
---|---|
Dynamic constant layout system |
|
Stencil buffer |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_Blender.h | cpp |
|
GRAPHICS_OBJ_Rasterizer.h | cpp |
|
Commit | Description |
---|---|
Alpha testing through shaders. |
|
Filename | Description |
---|---|
GRAPHICS_HELP_MatrixTranslator.h | cpp GRAPHICS_HELP_NormalMapTwerker.h GRAPHICS_HELP_TexturePreprocessor.h | cpp |
|
Commit | Description |
---|---|
Model loading |
|
Anisotropic filtering and mipmapping |
|
Filename | Description |
---|---|
PhongPSNormalMap.hlsl |
|
TestPlane.h | cpp |
|
Commit | Description |
---|---|
Tangen space normal mapping |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_BindablePool.h | cpp |
|
Commit | Description |
---|---|
Model hierarchy loading |
|
Mouse camera system |
|
Specular map loader |
|
BindablePool system |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_Mesh.h | cpp |
|
GRAPHICS_OBJ_DynamicVertex.cpp | GRAPHICS_OBJ_InputLayout.cpp |
|
Commit | Description |
---|---|
Model loading |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_DynamicVertex.h |
|
TexturedPhongVS.hlsl | TexturedPhongPS.hlsl |
|
AssTest.cpp.h | cpp |
|
Filename | Description |
---|---|
GRAPHICS_BUF_VertexBuffer.h | cpp |
|
Filename | Description |
---|---|
IndexedPhongVS.hlsl | IndexedPhongPS.hlsl |
|
GRAPHICS_OBJ_TestObject.h | GRAPHICS_OBJ_Cylinder.h | cpp |
|
Filename | Description |
---|---|
Commit details |
|
Filename | Description |
---|---|
GRAPHICS_LGT_PointLight.h | cpp |
|
GRAPHICS_OBJ_SolidSphere.h | cpp |
|
PhongVS.hlsl | PhongPS.hlsl |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_IndexedTriangleList.h |
|
Filename | Description |
---|---|
SYS_CLASS_ImguiManager.h | cpp |
|
GRAPHICS_OBJ_Camera.h | cpp |
|
Filename | Description |
---|---|
SYS_CLASS_Graphics.h | cpp | SYS_CLASS_App.h | cpp |
|
Filename | Description |
---|---|
GRAPHICS_OBJ_Surface.h | cpp |
|
GRAPHICS_SET_GDIPlusManager.h | cpp |
|
GRAPHICS_OBJ_Texture.h | cpp |
|
GRAPHICS_OBJ_Sampler.h | cpp |
|
None.
Filename | Description |
---|---|
SYS_SET_Math.h |
|
GRAPHICS_OBJ_IndexedTriangleList.h |
|
GRAPHICS_OBJ_Cube.h | GRAPHICS_OBJ_Cone.h | GRAPHICS_OBJ_Prism.h | GRAPHICS_OBJ_Plane.h | GRAPHICS_OBJ_Sphere.h |
|
None.
Filename | Description |
---|---|
GRAPHICS_OBJ_Drawable.h | cpp |
|
GRAPHICS_OBJ_Bindable.h | cpp |
|
GRAPHICS_BUF_VertexBuffer.h | cpp |
|
GRAPHICS_BUF_IndexBuffer.h | cpp |
|
GRAPHICS_OBJ_PixelShader.h | cpp | VertexShader.h | cpp |
|
GRAPHICS_OBJ_InputLayout.h | cpp |
|
GRAPHICS_BUF_ConstantBuffers.h |
|
GRAPHICS_BUF_TransformCBuffer.h | cpp |
|
GRAPHICS_OBJ_Topology.h | cpp |
|
GRAPHICS_OBJ_StaticDrawInfo.h |
|
GRAPHICS_OBJ_Box.h | cpp |
|
SYS_SET_GraphicsThrowMacros.h | SYS_SET_WindowsThrowMacros.h |
|
Filename | Description |
---|---|
Commit detail |
|
None.
Filename | Description |
---|---|
SYS_CLASS_Graphics.h | cpp |
|
SYS_CLASS_IO_Mouse.h | cpp |
|
SYS_CLASS_IO_Keyboard.h | cpp |
|
Filename | Description |
---|---|
SYS_MAIN_Loop.h | cpp |
|
SYS_CLASS_Graphics.h | cpp |
|
SYS_CLASS_App.h | cpp |
|
SYS_CLASS_MFException.h | cpp |
|
SYS_CLASS_Window.h | cpp |
|
SYS_CLASS_IO_Mouse.h | cpp | Keyboard.h | cpp |
|
None.