Skip to content

Commit 300aee1

Browse files
authored
Falcor 4.2 (#253)
1 parent 63c77d4 commit 300aee1

File tree

743 files changed

+13403
-8002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

743 files changed

+13403
-8002
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Bin/*
1212
*.pyc
1313
*.o
1414
*slang-dump-*
15+
*.mp4
1516
Source/Externals/.packman/*
1617
Media
1718
Tools/.packman

Build/deploycommon.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ IF not exist %OutDir%\Data\ mkdir %OutDir%\Data >nul
1818
call %~dp0\deployproject.bat %FalcorDir% %OutDir%
1919

2020
rem Copy externals
21-
robocopy %ExtDir%\Python\ %OutDir% Python37*.dll /r:0 >nul
21+
robocopy %ExtDir%\Python\ %OutDir% Python36*.dll /r:0 >nul
2222
robocopy %ExtDir%\Python %OutDir%\Python /E /r:0 >nul
2323
robocopy %ExtDir%\AntTweakBar\lib %OutDir% AntTweakBar64.dll /r:0 >nul
2424
robocopy %ExtDir%\FreeImage %OutDir% freeimage.dll /r:0 >nul
2525
robocopy %ExtDir%\assimp\bin\%2 %OutDir% *.dll /r:0 >nul
2626
robocopy %ExtDir%\FFMpeg\bin\%2 %OutDir% *.dll /r:0 >nul
27-
rem robocopy %ExtDir%\dxcompiler\%2 %OutDir% dxcompiler.dll /r:0 >nul
28-
robocopy %ExtDir%\openvr\bin\win64 %OutDir% openvr_api.dll /r:0 >nul
2927
robocopy %ExtDir%\Slang\bin\windows-x64\release %OutDir% *.dll /r:0 >nul
3028
robocopy %ExtDir%\GLFW\lib %OutDir% *.dll /r:0 >nul
3129
robocopy %ExtDir%\WinPixEventRuntime\bin\x64 %OutDir% WinPixEventRuntime.dll /r:0 >nul

Docs/Getting-Started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The `RenderPasses` folder contains a number of components ("Render Passes") that
2424
There are two main workflows when using Falcor:
2525

2626
### Render Graphs
27-
The recommended workflow when prototyping or implementing rendering techniques is to create render passes, render graphs, then render them with Mogwai. The [tutorials](../Tutorials/index.md) focus on this workflow.
27+
The recommended workflow when prototyping or implementing rendering techniques is to create render passes, render graphs, then render them with Mogwai. The [tutorials](./Tutorials/index.md) focus on this workflow.
2828

2929
#### To run a sample Render Graph:
3030
1. Build the Falcor Solution
@@ -65,9 +65,9 @@ When running from Visual Studio:
6565
- Any directory that was added to the data directories list by calling `addDataDirectory()`.
6666
- Falcor looks for Shader files relative to your project folder.
6767

68-
Upon building, a project's `Data` folders and shader files will be automatically deployed to the `Data` and `Shader` folders in the executable directory while preserving folder hierarchy. When running an application from its executable, Falcor will search in these folders instead. This allows the build output folder to be self-contained for easy sharing.
68+
Upon building, a project's `Data` folder and shader files will be automatically deployed to the `Data` and `Shaders` folders in the executable directory while preserving folder hierarchy. When running an application from its executable, Falcor will search in these folders instead. This allows the build output folder to be self-contained for easy sharing.
6969

70-
The best practice is to create a directory called `Data/` next to your **project** file and place all your data files there. Your shader files should also have a `.slang`, `.slangh`, `.hlsl`, or `.hlsli` extension. Files with these extensions will be marked with the `Shader Source` item type in Visual Studio, and only these files will be deployed. Headers with a `.h` should be used for host-only files. Headers that will be shared between host and shader files should use the `.slangh` extension.
70+
The best practice is to create a directory called `Data` next to your **project** file and place all your data files there. Your shader files should also have a `.slang`, `.slangh`, `.hlsl`, or `.hlsli` extension. Files with these extensions will be marked with the `Shader Source` item type in Visual Studio, and only these files will be deployed. Headers with a `.h` should be used for host-only files. Headers that will be shared between host and shader files should use the `.slang` or `.slangh` extension.
7171

7272
To search for a data or shader file, call `findFileInDataDirectories()` or `findFileInShaderDirectories()` respectively.
7373

Docs/Tutorials/01-Mogwai-Usage.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
--------
44

5+
# Mogwai Usage
6+
57
## Building Mogwai
68

79
In Visual Studio:
@@ -13,16 +15,26 @@ In Visual Studio:
1315
## Running Mogwai
1416

1517
Run Mogwai from within Visual Studio (by pressing Ctrl+F5), or from the command prompt using:
18+
1619
```
17-
Mogwai .exe [options]
20+
Mogwai {OPTIONS}
21+
22+
Mogwai render application.
1823
19-
Options:
20-
-script <file> Load this script at startup (`.py` files)
21-
-silent Launch Mogwai minimized with input and message boxes disabled.
22-
Use with -script to run a renderer in the background.
23-
-logfile <path> Specify where to save the log file. By default, this is next to the executable.
24+
OPTIONS:
25+
26+
-h, --help Display this help menu.
27+
-s[path], --script=[path] Python script file to run.
28+
-l[path], --logfile=[path] File to write log into.
29+
--silent Starts Mogwai with a minimized window
30+
and disables mouse/keyboard input as
31+
well as error message dialogs.
32+
--width=[pixels] Initial window width.
33+
--height=[pixels] Initial window height.
2434
```
2535

36+
Using `--silent` together with `--script` allows to run Mogwai for rendering in the background.
37+
2638
If you start it without specifying any options, Mogwai starts with a blank screen.
2739

2840
## Loading Scripts and Assets
@@ -40,7 +52,7 @@ Mogwai loads the scene specified by the script, if any. If the script did not lo
4052
A sample Arcade scene is included, which can be found at `Media/Arcade/Arcade.fscene`.
4153

4254
## Mogwai UI
43-
Once you have a script (and optionally, a scene) loaded, you should see something similar to
55+
Once you have a script (and optionally, a scene) loaded, you should see something similar to
4456

4557
![MogwaiUI](./images/MogwaiUI.png)
4658

@@ -79,4 +91,4 @@ The following is a list of available controls:
7991
`Shift` - Speeds up camera movement when held down\
8092
`Ctrl` - Slows down camera movement when held down\
8193
`Z` - Magnify the currently hovered area\
82-
`Mouse Wheel` - Change zoom level when magnifying a pixel
94+
`Mouse Wheel` - Change zoom level when magnifying a pixel

Docs/Tutorials/02-Implementing-a-Render-Pass.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
--------
44

5+
# Implementing a Render Pass
6+
57
Now that you've successfully loaded a render graph into Mogwai through a script, let's create one. A render graph is formed from a number of component render passes. This tutorial will focus on creating render passes through an example pass that blits a source texture into a destination texture; graph creation and editing will be the subject of the next.
68

79
## Creating a Render Pass Project
@@ -89,4 +91,4 @@ extern "C" __declspec(dllexport) void getPasses(Falcor::RenderPassLibrary& lib)
8991
}
9092
```
9193

92-
We will ignore further details regarding render passes and their implementation for the purposes of this tutorial. Additional information can be found [here](../Usage/Render-Passes.md).
94+
We will ignore further details regarding render passes and their implementation for the purposes of this tutorial. Additional information can be found [here](../Usage/Render-Passes.md).

Docs/Tutorials/03-Creating-and-Editing-Render-Graphs.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
--------
44

5+
# Creating and Editing Render Graphs
6+
57
Now that we've written a simple render pass, we turn our attention to creating and editing render graphs. There are two methods of doing this: using the Render Graph Editor and using Python scripting. We will cover both in this tutorial though using the editor is recommended.
68

79
## Render Graph Editor
@@ -71,9 +73,9 @@ The graph containing `ExampleBlitPass` we created using the editor above would l
7173
```python
7274
def render_graph_ExampleBlitPass():
7375
g = RenderGraph("ExampleBlitPass Example")
74-
ExampleBlitPass = RenderPass("ExampleBlitPass")
76+
ExampleBlitPass = createPass("ExampleBlitPass")
7577
g.addPass(ExampleBlitPass, "MyBlitPass")
76-
ImageLoader = RenderPass("ImageLoader", {'filename': 'Cubemaps\\Sorsele3\\posz.jpg',
78+
ImageLoader = createPass("ImageLoader", {'filename': 'Cubemaps\\Sorsele3\\posz.jpg',
7779
'mips': False, 'srgb': True, 'arrayIndex': 0, 'mipLevel': 0})
7880
g.addPass(ImageLoader, "ImageLoader")
7981
g.addEdge("ImageLoader.dst", "MyBlitPass.input")

Docs/Tutorials/04-Writing-Shaders.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
--------
44

5+
# Writing Shaders
6+
57
Now that we've written a basic render pass and render graph, let's look at writing more complex passes that use shaders. Falcor uses the Slang shading language and compiler, and files should use one of the following extensions: `.slang`, `.slangh`, `.hlsl`, `.hlsli`. For more information on best practices for working with shaders in Falcor, please refer to the *Using Shaders and Data Files* section of the [Getting Started](../Getting-Started.md) page.
68

79
For this tutorial, we'll create a pass that renders a scene as a wireframe of a particular color.
@@ -60,15 +62,17 @@ WireframePass::WireframePass()
6062
```
6163

6264
### `setScene()`
63-
Our first render pass had no need for a `Scene` object; however, this pass does and will need this function to set `mpScene`. We will also need to add all scene macro definitions to `mpProgram` and create our `GraphicsVars` so that we can bind shader values later in `execute()`. These are done like so:
65+
Our first render pass had no need for a `Scene` object; however, this pass does and will need this function to set `mpScene`. We first need to set `mpScene` to the scene that's passed in then add all scene defines to `mpProgram`. We then create our `GraphicsVars` so that we can bind shader variables later in `execute()`. These are done like so:
6466
```c++
6567
void WireframePass::setScene(RenderContext* pRenderContext, const Scene::SharedPtr& pScene)
6668
{
6769
mpScene = pScene;
68-
mpProgram->addDefines(mpScene->getSceneDefines());
70+
if (mpScene) mpProgram->addDefines(mpScene->getSceneDefines());
6971
mpVars = GraphicsVars::create(mpProgram->getReflector());
7072
}
7173
```
74+
#### Why scene defines?
75+
We need some way to tell Slang/HLSL exactly how many resources the scene needs to bind and need to ensure that this scene data is portable between shaders. However, there's currently no way to do this automatically, so we use scene defines to communicate this information.
7276
7377
### `execute()`
7478
This function will need to perform several operations: create and bind an FBO for our output to the `GraphicsState`, set the render state, and render our scene by calling `Scene::render()`.
@@ -94,7 +98,7 @@ With our scene, shader, and both the `GraphicsState` and `RasterizerState` set u
9498
```c++
9599
mpScene->render(pRenderContext, mpGraphicsState.get(), mpGraphicsVars.get(), renderFlags);
96100
```
97-
Your `execute()` function should now look like this:
101+
Your `execute()` function should now look like this, with a check for `mpScene` so we avoid accessing the scene when it isn't set:
98102
```c++
99103
void WireframePass::execute(RenderContext* pRenderContext, const RenderData& renderData)
100104
{
@@ -103,14 +107,17 @@ void WireframePass::execute(RenderContext* pRenderContext, const RenderData& ren
103107
pRenderContext->clearFbo(pTargetFbo.get(), clearColor, 1.0f, 0, FboAttachmentType::All);
104108
mpGraphicsState->setFbo(pTargetFbo);
105109
106-
// Set render state
107-
Scene::RenderFlags renderFlags = Scene::RenderFlags::UserRasterizerState;
108-
mpVars["PerFrameCB"]["gColor"] = float4(0, 1, 0, 1);
110+
if (mpScene)
111+
{
112+
// Set render state
113+
Scene::RenderFlags renderFlags = Scene::RenderFlags::UserRasterizerState;
114+
mpVars["PerFrameCB"]["gColor"] = float4(0, 1, 0, 1);
109115
110-
mpScene->render(pRenderContext, mpGraphicsState.get(), mpVars.get(), renderFlags);
116+
mpScene->render(pRenderContext, mpGraphicsState.get(), mpVars.get(), renderFlags);
117+
}
111118
}
112119
```
113120

114-
Using the Render Graph Editor, create a graph solely containing this pass then launch it in Mogwai. Don't worry about needing to load a scene; Mogwai will load the Arcade scene by default. You should see something similar to this:
121+
Using the Render Graph Editor, create a graph solely containing this pass then launch it in Mogwai. You should see a black screen as there is no scene currently loaded. Load a scene by going to `File -> Load Scene`, and you should now see the wireframe for the scene you selected. We used Arcade.fscene (located in the `Media` folder), which looks like this:
115122

116123
![WireframePass](./images/WireframePass.png)
6.18 KB
Loading

Docs/Usage/Environment-Variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ The following environment variables are used in Falcor:
1010
|-----|-----|
1111
| `FALCOR_DEVMODE` | Set to `1` to enable development mode. In development mode, shader and data files are picked up from the `Source` folder instead of the binary output directory allowing for shader hot reloading (`F5`). Note that this environment variable is set by default when launching any of the Falcor projects from Visual Studio. |
1212
| `FALCOR_MEDIA_FOLDERS` | Specifies a semi-colon (`;`) separated list of absolute path names containing Falcor scenes. Falcor will search in these paths when loading a scene from a relative path name. |
13-
| `FALCOR_GPU_VENDOR_ID` | Specify which GPU vendor to use for rendering. This is useful when having multiple GPUs in a system (e.g. laptop with both integrated and discrete GPUs). Use `0x10DE` to select the NVIDIA GPU. |
14-
| `FALCOR_GPU_DEVICE_ID` | Specify which GPU to use for rendering. This is useful when having multiple GPUs that can be used in parallel by multiple Falcor instances. |
13+
| `FALCOR_GPU_VENDOR_ID` | Specify which GPU vendor to use for rendering. This is useful when having multiple GPUs in a system (e.g. laptop with both integrated and discrete GPUs). Falcor tries to select an NVIDIA GPU by default. |
14+
| `FALCOR_GPU_DEVICE_ID` | Of the GPUs matching the vendor ID specified by `FALCOR_GPU_VENDOR_ID` (or NVIDIA GPUs if unspecified), selects which GPU index to choose. This is useful when having multiple GPUs that can be used in parallel by multiple Falcor instances. By default, the first GPU (ID 0) is used. |

Docs/Usage/Path-Tracer.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- From the top menu bar, click `Load Script`, then navigate to `PathTracer.py`.
1414
- Press `Ctrl + O`, then navigate to `PathTracer.py`.
1515
- Drag and drop `PathTracer.py` into the application window.
16+
- Load at startup using the Mogwai `--script` command line option.
1617
5. Load a model or scene using one of the following methods. A sample scene is included, located at `Media/Arcade/Arcade.fscene`. Falcor can also load any format supported by Assimp.
1718
- From the top menu bar, click `Load Scene`, then select a file.
1819
- Press `Ctrl + Shift + O` then select a file.
@@ -22,7 +23,7 @@
2223

2324
![PathTracer-overview](./images/PathTracer-Overview.png)
2425

25-
The `MegakernelPathTracer` render pass implements an unbiased path tracer in DXR. Paths are created in a raygen shader and hit/miss points are reported back from the respective shader stages. The raygen shader loops over path segments up to the maximum configured path length.
26+
The `MegakernelPathTracer` render pass implements an unbiased path tracer in DXR 1.0. Paths are created in a raygen shader and hit/miss points are reported back from the respective shader stages. The raygen shader loops over path segments up to the maximum configured path length.
2627

2728
For each pixel on screen, `samplesPerPixel` paths are traced.
2829
At each path vertex (black dots), a configurable number `lightSamplesPerVertex` of shadow rays (dashed lines) is traced to sampled light sources.
@@ -43,7 +44,7 @@ The V-buffer input is the default. It is configured using a parameter `useVBuffe
4344

4445
When configured to use G-buffer input:
4546

46-
- `bitangentW` is optional and only really needed for anisotropic materials (not supported yet) or if consistent tangent frames are needed. If not connected, a tangent frame is created based on the normal.
47+
- `tangentW` is optional and only really needed for anisotropic materials (not supported yet) or if consistent tangent frames are needed. If not connected, a tangent frame is created based on the normal.
4748
- `viewW` is optional but needed for correct shading with depth-of-field (otherwise the view direction points towards the camera origin, instead of the actual lens sample position).
4849
- `vbuffer` is optional but needed for correct shading with dielectrics (glass), as the renderer fetches the material ID from this input.
4950
- All other inputs are required.
@@ -52,7 +53,9 @@ When configured to use G-buffer input:
5253

5354
- All outputs are optional.
5455
- Only outputs that are connected are computed.
55-
- The `rayCount` is a fullscreen 32-bit integer buffer storing number of rays traced per pixel (for debugging/visualization purposes).
56+
- The `rayCount` is a fullscreen 32-bit uint buffer storing number of rays traced per pixel for debugging/visualization purposes.
57+
- The `pathLength` is a fullscreen 32-bit uint buffer storing the path length per pixel for debugging/visualization purposes.
58+
- The `time` output is a fullscreen 32-bit uint buffer with GPU execution time per pixel (requires NVAPI).
5659

5760

5861
### Example: Progressive path tracer in the render graph editor
@@ -70,48 +73,48 @@ Note: Multiple importance sampling is applied to the strategies marked MIS.
7073

7174
### BSDF sampling (MIS)
7275

73-
- Disney isotropic diffuse
74-
- Trowbridge-Reitz GGX specular reflection/transmission
75-
- Diffuse/specular reflection or transmission is chosen stochastically
76+
- Disney isotropic diffuse.
77+
- Trowbridge-Reitz GGX specular reflection/transmission with VNDF sampling.
78+
- Diffuse/specular reflection or transmission is chosen stochastically.
7679

7780
### Environment map sampling (MIS)
7881

79-
- A hierarchical importance map (mipmap) is computed at startup
80-
- Importance sampling by hierarchical warping of 2D uniform number
81-
- The PDF is proportional to incoming radiance, ignoring cosine term and visiblity
82+
- A hierarchical importance map (mipmap) is computed at startup.
83+
- Importance sampling by hierarchical warping of 2D uniform number.
84+
- The PDF is proportional to incoming radiance, ignoring cosine term and visiblity.
8285

8386
### Emissive meshes light sampling (MIS)
8487

85-
- A light BVH is built over all emissive triangles
86-
- The per-triangle flux is pre-integrated and zero emissive triangles culled
87-
- Hierarchical importance sampling (see the book "Ray Tracing Gems", chapter 18)
88-
- There is an optional uniform light sampling mode
88+
- A light BVH is built over all emissive triangles.
89+
- The per-triangle flux is pre-integrated and zero emissive triangles culled.
90+
- Hierarchical importance sampling (see the book "Ray Tracing Gems", chapter 18).
91+
- There is an optional uniform light sampling mode.
8992

9093
### Analytic light sampling
9194

92-
- Used for point, directional, and quad/disc/sphere area lights
93-
- Lights are specified in the FBX file (point, directional) or scene file (.fscene)
94-
- Each light source is selected with equal probability
95+
- Used for point, directional, distant, and quad/disc/sphere area lights.
96+
- Lights are specified in the FBX file (point, directional) or Python scene file (.pyscene).
97+
- Each light source is selected with equal probability.
9598

9699

97100
## Validation/debugging tools
98101

99102
### MinimalPathTracer
100103

101-
- Separate `MinimalPathTracer` pass
104+
- Separate `MinimalPathTracer` pass.
102105
- Naive/simple to be easy to verify, no importance sampling or MIS etc.
103-
- Produces ground truth images (but converges slowly)
104-
- Does not support dielectric materials (transmission)
106+
- Produces ground truth images (but converges slowly).
107+
- Does not support transmission or nested dielectric materials yet.
105108

106109
### ErrorMeasurePass
107110

108-
- Takes a source image and a reference image
109-
- The reference can either be loaded from disk, or taken from a pass input
110-
- Makes it possible to run two separate configs in parallel, compare their output
111+
- Takes a source image and a reference image.
112+
- The reference can either be loaded from disk, or taken from a pass input.
113+
- Makes it possible to run two separate configs in parallel, compare their output.
111114

112115
### Shader print/assert
113116

114-
- The `MegakernelPathTracer` pass supports debugging with `print()` in the shader
115-
- Click *Pixel Debug* in the UI to enable, click on a pixel to show it's output
116-
- It's useful to freeze the random seed (UI option) to avoid flickering values
117-
- There is also an `assert()` call that prints the coordinates of triggered asserts in the UI
117+
- The `MegakernelPathTracer` pass supports debugging with `print()` in the shader.
118+
- Click *Pixel Debug* in the UI to enable, click on a pixel to show it's output.
119+
- It's useful to freeze the random seed (UI option) to avoid flickering values.
120+
- There is also an `assert()` call that prints the coordinates of triggered asserts in the UI.

0 commit comments

Comments
 (0)