Skip to content

Commit

Permalink
4.1 (#234)
Browse files Browse the repository at this point in the history
* Falcor 4 Revision 1
  • Loading branch information
kyaoNV authored Apr 18, 2020
1 parent 76816c0 commit 57e3d42
Show file tree
Hide file tree
Showing 269 changed files with 4,786 additions and 2,529 deletions.
1 change: 0 additions & 1 deletion Build/deploycommon.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ robocopy %ExtDir%\FreeImage %OutDir% freeimage.dll /r:0 >nul
robocopy %ExtDir%\assimp\bin\%2 %OutDir% *.dll /r:0 >nul
robocopy %ExtDir%\FFMpeg\bin\%2 %OutDir% *.dll /r:0 >nul
rem robocopy %ExtDir%\dxcompiler\%2 %OutDir% dxcompiler.dll /r:0 >nul
robocopy %ExtDir%\OptiX\bin64 %OutDir% *.dll /r:0 >nul
robocopy %ExtDir%\openvr\bin\win64 %OutDir% openvr_api.dll /r:0 >nul
robocopy %ExtDir%\Slang\bin\windows-x64\release %OutDir% *.dll /r:0 >nul
robocopy %ExtDir%\GLFW\lib %OutDir% *.dll /r:0 >nul
Expand Down
10 changes: 5 additions & 5 deletions Docs/Tutorials/04-Writing-Shaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This function will need to perform several operations: create and bind an FBO fo
We can create and bind an FBO for our renderer to render to by first calling `Fbo::create()` on our output texture, clearing it to remove any data from previous executions (preventing it from leaving permanent trails if you try to move the camera), and calling `GraphicsState::setFbo()` to bind it. This step looks like this:
```c++
auto pTargetFbo = Fbo::create({ renderData["output"]->asTexture() });
const glm::vec4 clearColor(0, 0, 0, 1);
const float4 clearColor(0, 0, 0, 1);
pRenderContext->clearFbo(pTargetFbo.get(), clearColor, 1.0f, 0, FboAttachmentType::All);
mpGraphicsState->setFbo(pTargetFbo);
```
Expand All @@ -86,7 +86,7 @@ mpGraphicsState->setFbo(pTargetFbo);
We need to perform two operations here: indicate that we want to use a custom `RasterizerState` and bind all necessary values to our shader. We can indicate that we're using a custom `RasterizerState` by creating a `Scene::Renderflags` object and setting the flag `Scene::RenderFlags::UserRasterizerState`. Binding shader values is also fairly straightforward as Falcor allows you to set shader values in the `GraphicsVars` object in the same way as you would set values in an array. Our shader requires a single color value, `gColor`, which is located inside the `perFrameCB` constant buffer. This step should look like this:
```c++
Scene::RenderFlags renderFlags = Scene::RenderFlags::UserRasterizerState;
mpVars["perFrameCB"]["gColor"] = vec4(0, 1, 0, 1);
mpVars["perFrameCB"]["gColor"] = float4(0, 1, 0, 1);
```

#### Rendering a Scene Using the Shader
Expand All @@ -99,18 +99,18 @@ Your `execute()` function should now look like this:
void WireframePass::execute(RenderContext* pRenderContext, const RenderData& renderData)
{
auto pTargetFbo = Fbo::create({ renderData["output"]->asTexture() });
const glm::vec4 clearColor(0, 0, 0, 1);
const float4 clearColor(0, 0, 0, 1);
pRenderContext->clearFbo(pTargetFbo.get(), clearColor, 1.0f, 0, FboAttachmentType::All);
mpGraphicsState->setFbo(pTargetFbo);
// Set render state
Scene::RenderFlags renderFlags = Scene::RenderFlags::UserRasterizerState;
mpVars["PerFrameCB"]["gColor"] = vec4(0, 1, 0, 1);
mpVars["PerFrameCB"]["gColor"] = float4(0, 1, 0, 1);
mpScene->render(pRenderContext, mpGraphicsState.get(), mpVars.get(), renderFlags);
}
```

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:

![WireframePass](./images/WireframePass.png)
![WireframePass](./images/WireframePass.png)
2 changes: 1 addition & 1 deletion Docs/Tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

1. [Mogwai Usage](./01-Mogwai-Usage.md)
2. [Implementing Render Passes](./02-Implementing-a-Render-Pass.md)
3. [Creating and Editing Render Graphs](./03-Creating-And-Editing-Render-Graphs.md)
3. [Creating and Editing Render Graphs](./03-Creating-and-Editing-Render-Graphs.md)
4. [Writing Shaders](./04-Writing-Shaders.md)
1 change: 1 addition & 0 deletions Docs/Usage/Render-Passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static void regExampleClass(ScriptBindings::Module& m)
{
auto c = m.regClass(SomeClass);
c.property("property", &SomeClass::getProperty, &SomeClass::setProperty);
c.roProperty("readOnlyProperty", &SomeClass::getReadOnlyProperty);
}
```
This allows you to access the bound properties of your pass the same way you would access properties for any given instance of a Python class.
Expand Down
4 changes: 2 additions & 2 deletions Docs/Usage/Scene-Creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Scene::SharedPtr pScene = pBuilder->getScene();
Model loading functions also provide an optional parameter for creating multiple instances of a model from file. The following example loads a model from file and creates two instances at positions [-5, 0, 0] and [5, 0, 0].
```c++
SceneBuilder::InstanceMatrices instances = {
glm::translate(vec3(-5.0f, 0.0f, 0.0f)),
glm::translate(vec3(5.0f, 0.0f, 0.0f))
glm::translate(float3(-5.0f, 0.0f, 0.0f)),
glm::translate(float3(5.0f, 0.0f, 0.0f))
};

SceneBuilder::SharedPtr pBuilder = SceneBuilder::create("path/to/model.file", SceneBuilder::Flags::Default. instances);
Expand Down
66 changes: 66 additions & 0 deletions Docs/Usage/Scene-Formats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
### [Index](../index.md) | [Usage](./index.md) | Scene Formats

--------

# Scene Formats

Falcor uses [Assimp](https://github.com/assimp/assimp) as its core asset loader and can load all file formats Assimp supports by default.

From assets, Falcor will import:
- Scene Graph
- Meshes
- Materials
- Diffuse Texture
- Metal-Rough Shading Model (Default)
- RGB: Base Color
- Spec-Gloss Shading Model (Default for OBJ only)
- RGB: Diffuse Color
- Specular Parameters Texture
- Metal-Rough Shading Model (Default)
- R: Occlusion
- G: Roughness
- B: Metallic
- Spec-Gloss Shading Model (Default for OBJ only)
- RGB: Specular Color
- A: Glossiness
- Normals Texture
- Occlusion Texture (Used for Spec-Gloss shading model only)
- Emissive Color/Texture
- The first camera
- Point lights
- Directional lights
- Keyframe animations
- Skinned animations


## Python Scene Files

You can also leverage Falcor's scripting system to set values in the scene on load that are not supported by standard file formats. These are also written in Python, but are formatted differently than normal Falcor scripts.

### Usage

The first line must be a Python comment containing only a path to the base asset to be loaded. File paths in Python scene files may be relative to the file itself, in addition to standard Falcor data directories.

```python
# BistroInterior.fbx
```

The asset will be loaded and will be bound to an object called `scene`. Through this object, you have access to any script bindings accessible through Scenes. See the [scripting documentation](./Scripting) for a full list of functions and properties.

Example:

```python
# BistroInterior.fbx
# Line above loads BistroInterior.fbx from the same folder as the script

scene.setEnvMap("BistroInterior.hdr") # Set the environment map to "BistroInterior.hdr" located in the same folder as the script

bottle_wine = scene.getMaterial("TransparentGlassWine") # Get a material from the scene by name

# Set material properties
bottle_wine.indexOfRefraction = 1.55
bottle_wine.specularTransmission = 1
bottle_wine.doubleSided = True
bottle_wine.nestedPriority = 2
bottle_wine.volumeAbsorption = float3(0.7143, 1.1688, 1.7169)
```
Loading

0 comments on commit 57e3d42

Please sign in to comment.