Skip to content

Commit

Permalink
Merge branch 'main' into python_stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovbs96 authored Sep 30, 2024
2 parents fc5071a + 210266b commit 112587d
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ jobs:

- name: Deploy Web Viewer
if: matrix.build_javascript == 'ON' && github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
uses: JamesIves/github-pages-deploy-action@v4.6.4
with:
branch: gh-pages
folder: javascript/MaterialXView/dist
Expand Down
29 changes: 25 additions & 4 deletions libraries/bxdf/translation/standard_surface_to_gltf_pbr.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,24 @@
</dotproduct>

<!-- Metallic roughness -->
<ifequal name="base_color" type="color3">
<ifequal name="baseColor" type="color3">
<input name="value1" type="float" nodename="hasCoatColor" />
<input name="value2" type="float" value="0" />
<input name="in1" type="color3" nodename="scaledBaseColor" />
<input name="in2" type="color3" nodename="mixedBaseColor" />
</ifequal>
<ifgreater name="transmissionBaseColor" type="color3">
<input name="value1" type="float" interfacename="transmission_depth" />
<input name="value2" type="float" value="0" />
<input name="in1" type="color3" value="1, 1, 1" />
<input name="in2" type="color3" interfacename="transmission_color" />
</ifgreater>
<ifgreater name="base_color" type="color3">
<input name="value1" type="float" interfacename="transmission" />
<input name="value2" type="float" value="0" />
<input name="in1" type="color3" nodename="transmissionBaseColor" />
<input name="in2" type="color3" nodename="baseColor" />
</ifgreater>
<dot name="metallic" type="float">
<input name="in" type="float" interfacename="metalness" />
</dot>
Expand All @@ -96,9 +108,18 @@
<dot name="thickness" type="float">
<input name="in" type="float" interfacename="transmission_depth" />
</dot>
<dot name="attenuation_color" type="color3">
<input name="in" type="color3" interfacename="transmission_color" />
</dot>
<ifgreater name="transmissionAttenuationColor" type="color3">
<input name="value1" type="float" interfacename="transmission_depth" />
<input name="value2" type="float" value="0" />
<input name="in1" type="color3" interfacename="transmission_color" />
<input name="in2" type="color3" value="1, 1, 1" />
</ifgreater>
<ifgreater name="attenuation_color" type="color3">
<input name="value1" type="float" interfacename="transmission" />
<input name="value2" type="float" value="0" />
<input name="in1" type="color3" nodename="transmissionAttenuationColor" />
<input name="in2" type="color3" value="1, 1, 1" />
</ifgreater>

<!-- Sheen -->
<multiply name="sheen_color" type="color3">
Expand Down
9 changes: 9 additions & 0 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,6 +3240,15 @@ void Graph::graphButtons()
ImGui::BeginChild("Selection", ImVec2(paneWidth, 0), false, windowFlags);
ImVec2 windowPos = ImGui::GetWindowPos();

// Update cursorInRenderView to account for other windows overlapping the Render View (e.g. Menu dropdown).
cursorInRenderView &= ImGui::IsWindowHovered(ImGuiHoveredFlags_None);

// Update cursorInRenderView to account for visible scrollbar and scroll amount.
ImGuiContext* context = ImGui::GetCurrentContext();
bool hasScrollbar = context->CurrentWindow->ScrollbarY;
cursorInRenderView &= hasScrollbar ? mousePos.x < (tempWindowPos.x + screenSize.x - ImGui::GetStyle().ScrollbarSize) : true;
cursorInRenderView &= hasScrollbar ? mousePos.y < (tempWindowPos.y + screenSize.y - ImGui::GetScrollY()) : true;

// RenderView window
ImVec2 wsize = ImVec2((float) _renderer->getViewWidth(), (float) _renderer->getViewHeight());
_renderer->setViewWidth((int) screenSize[0]);
Expand Down
8 changes: 4 additions & 4 deletions source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ void testUniqueNames(mx::GenContext& context, const std::string& stage)
void shaderGenPerformanceTest(mx::GenContext& context)
{
mx::DocumentPtr nodeLibrary = mx::createDocument();
mx::FilePath currentPath = mx::FilePath::getCurrentPath();
const mx::FileSearchPath libSearchPath(currentPath);
const mx::FileSearchPath libSearchPath(mx::getDefaultDataSearchPath());

// Load the standard libraries.
loadLibraries({ "libraries" }, libSearchPath, nodeLibrary);
Expand Down Expand Up @@ -351,8 +350,9 @@ void shaderGenPerformanceTest(mx::GenContext& context)
}

// Read mtlx documents
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();
mx::FilePathVec testRootPaths;
testRootPaths.push_back("resources/Materials/Examples/StandardSurface");
testRootPaths.push_back(searchPath.find("resources/Materials/Examples/StandardSurface"));

std::vector<mx::DocumentPtr> loadedDocuments;
mx::StringVec documentsPaths;
Expand All @@ -367,7 +367,7 @@ void shaderGenPerformanceTest(mx::GenContext& context)
REQUIRE(loadedDocuments.size() > 0);
REQUIRE(loadedDocuments.size() == documentsPaths.size());

// Shuffle the order of documents and perform document library import validatation and shadergen
// Shuffle the order of documents and perform document library import validation and shadergen
std::mt19937 rng(0);
std::shuffle(loadedDocuments.begin(), loadedDocuments.end(), rng);
for (const auto& doc : loadedDocuments)
Expand Down
10 changes: 10 additions & 0 deletions source/MaterialXTest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@ When rendering tests are enabled through the `MATERIALX_TEST_RENDER` option, the
#### HTML Render Comparisons
- A `tests_to_html` Python script is provided in the [`python/MaterialXTest`](../../python/MaterialXTest) folder, which can be run to generate an HTML file comparing the rendered results in each shading language.
- Example render comparisons may be found in [commits to the MaterialX repository](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1164), and we encourage developers to post their own results when making changes that have the potential to impact generated shaders.

#### Benchmark Tests

Processing MaterialX documents and generating shaders is an integral part of many pipelines. MaterialX benchmark testing using [Catch2 benchmark framework](https://github.com/catchorg/Catch2/blob/devel/docs/benchmarks.md) and can be enabled using `MATERIALX_BUILD_BENCHMARK_TESTS` CMake macro.

Here is an example of how to run the benchmark test

`MaterialXTest.exe "GenShader: GLSL Performance Test" --benchmark-samples 10`

This will iterate and gather 10 samples of the test case and report low, mean and high timing results.
Loading

0 comments on commit 112587d

Please sign in to comment.