Skip to content

Commit

Permalink
Merge remote-tracking branch 'aswf/main' into graph_io
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokcb committed Jan 24, 2024
2 parents 1eafb29 + 8dbabce commit 5b801bf
Show file tree
Hide file tree
Showing 64 changed files with 380 additions and 270 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

## [1.38.9] - Development

### Added

- Added a [non-photorealistic rendering](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1631) data library to MaterialX, initially supporting the 'viewdirection' and 'facingratio' nodes.
- Added support for the generation of [pre-filtered environment maps](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1420) in MaterialX GLSL and MSL.
- Added support for the [creatematrix node](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1553) in shader generation.
- Added [floating popups](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1565) for hovered pins in the MaterialX Graph Editor.
- Added support for [UI attributes](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1623) and [enumerated values](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1632) in the MaterialX Web Viewer.
- Added [UI ranges](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1646) to the 'useSpecularWorkflow' and 'normal' inputs of the UsdPreviewSurface shading model.
- Added [versioning rules](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1664) for the MaterialX API and data libraries to the developer guide.
- Added initial C++ [fuzz tests](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1605) and [coverage tests](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1548) to GitHub Actions CI.
- Added [GCC 13, Clang 15](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1602), and [Python 3.12](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1588) builds to GitHub Actions CI.

### Changed

- Improved the logic for [connecting pins](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1569) in the MaterialX Graph Editor.
- Improved the robustness of [type pointer comparisons](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1665) in shader generation.
- Improved the handling of [filename inputs](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1547) in OSL shader generation.
- Reduced the size of the MaterialX data libraries, improving the use of [graph definitions](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1653) and merging [duplicate implementations](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1642).
- Updated the MaterialX Web Viewer to [three.js r152](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1615).
- Switched to a more efficient representation of [HDR images](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1616) in the MaterialX Web Viewer.
- Raised the minimum CMake version to [CMake 3.16](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1607).
- Updated the C++ unit test library to [Catch 2.13.10](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1566).

### Fixed

- Fixed the attenuation of [coated emission](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1534) in the Standard Surface shading model.
- Fixed the implementation of the [overlay node](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1539) in shader generation.
- Fixed an edge case for [transform nodes](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1560) in GLSL and MSL shader generation.
- Fixed the implementation of [mx_hsvtorgb](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1584) in MDL shader generation.
- Fixed [scroll wheel interactions](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1578) across windows of the MaterialX Graph Editor.
- Fixed the generation of unused [imgui.ini files](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1570) in the MaterialX Graph Editor.
- Fixed a dependency on [module import order](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1595) in MaterialX Python.
- Fixed an [off-by-one index check](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1582) in Element::setChildIndex.
- Fixed a [missing null check](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1601) in Graph::propertyEditor.
- Fixed cases where [absolute paths](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1603) were stored in MaterialXConfig.cmake.

## [1.38.8] - 2023-09-08

### Added
Expand Down
19 changes: 17 additions & 2 deletions documents/DeveloperGuide/MainPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,24 @@ Building the `install` target of your project will install the MaterialX C++ and

### MaterialX Versioning

The MaterialX codebase uses a modified semantic versioning system where the *major* and *minor* versions match that of the corresponding MaterialX [specification](https://www.materialx.org/Specification.html), and the *build* version represents engineering advances within that specification version. MaterialX documents are similarly marked with the specification version they were authored in, and they are valid to load into any MaterialX codebase with an equal or higher specification version.
The MaterialX codebase uses a modified semantic versioning system where the *major* and *minor* versions match that of the corresponding MaterialX [specification](https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.Specification.md), and the *build* version represents engineering advances within that specification version. MaterialX documents are similarly marked with the specification version they were authored in, and they are valid to load into any MaterialX codebase with an equal or higher specification version.

Upgrading of MaterialX documents from earlier versions is handled at import time by the Document::upgradeVersion method, which applies the syntax and node interface upgrades that have occurred in previous specification revisions. This allows the syntax conventions of MaterialX and the names and interfaces of nodes to evolve over time, without invalidating documents from earlier versions.
Upgrading of MaterialX documents from earlier versions is handled at import time by the `Document::upgradeVersion` method, which applies the syntax and node interface upgrades that have occurred in previous specification revisions. This allows the syntax conventions of MaterialX and the names and interfaces of nodes to evolve over time, without invalidating documents from earlier versions.

#### MaterialX API Changes

The following rules describe the categories of changes to the [MaterialX API](https://materialx.org/docs/api/classes.html) that are allowed in version upgrades:

- In *build* version upgrades, only non-breaking changes to the MaterialX API are allowed. For any API call that is modified in a build version upgrade, backwards compatibility should be maintained using deprecated C++ and Python wrappers for the original API call.
- In *minor* and *major* version upgrades, breaking changes to the MaterialX API are allowed, though their benefit should be carefully weighed against their cost. Any breaking changes to API calls should be highlighted in the release notes for the new version.

#### MaterialX Data Library Changes

The following rules describe the categories of changes to the [MaterialX Data Libraries](https://github.com/AcademySoftwareFoundation/MaterialX/tree/main/libraries) that are allowed in version upgrades:

- In *build* version upgrades, only additive changes and fixes to the MaterialX data libraries are allowed. Additive changes are allowed to introduce new nodes, node versions, and node inputs with backwards-compatible default values. Data library fixes are allowed to update a node implementation to improve its alignment with the specification, without making any changes to its name or interface.
- In *minor* version upgrades, changes to the names and interfaces of MaterialX nodes are allowed, with the requirement that version upgrade logic be used to maintain the validity and visual interpretation of documents from earlier versions.
- In *major* version upgrades, changes to the syntax rules of MaterialX documents are allowed, with the requirement that version upgrade logic be used to maintain the validity and visual interpretation of documents from earlier versions. These changes usually require synchronized updates to both the MaterialX API and data libraries.

### Additional Links

Expand Down
56 changes: 49 additions & 7 deletions javascript/MaterialXView/source/dropHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import * as THREE from 'three';
import * as fflate from 'three/examples/jsm/libs/fflate.module.js';

const debugFileHandling = false;
let loadingCallback;
let loadingCallback = null;
let sceneLoadingCallback = null;

export function setLoadingCallback(cb) {
loadingCallback = cb;
}

export function setSceneLoadingCallback(cb)
{
sceneLoadingCallback = cb;
}

export function dropHandler(ev) {
if (debugFileHandling) console.log('File(s) dropped', ev.dataTransfer.items, ev.dataTransfer.files);

Expand Down Expand Up @@ -130,14 +136,22 @@ async function handleFilesystemEntries(entries) {
'node_modules',
]

let isGLB = false;
let haveMtlx = false;
for (let entry of entries) {
if (debugFileHandling) console.log("file entry", entry)
if (entry.isFile) {
if (debugFileHandling) console.log("single file", entry);
if (debugFileHandling)
console.log("single file", entry);
if (fileIgnoreList.includes(entry.name)) {
continue;
}
allFiles.push(entry);

if (entry.name.endsWith('glb')) {
isGLB = true;
break;
}
}
else if (entry.isDirectory) {
if (dirIgnoreList.includes(entry.name)) {
Expand Down Expand Up @@ -198,7 +212,28 @@ async function handleFilesystemEntries(entries) {
return 0;
});

if (debugFileHandling) console.log("all files", allFiles);
if (isGLB)
{
console.log("Load GLB file", allFiles[0]);

const rootFile = allFiles[0];
THREE.Cache.add(rootFile.fullPath, await getBufferFromFile(rootFile));

if (debugFileHandling) console.log("CACHE", THREE.Cache.files);

sceneLoadingCallback(rootFile);
return;
}

if (!allFiles[0].name.endsWith('mtlx'))
{
console.log("No MaterialX files dropped. Skipping content.");
return;
}

if (debugFileHandling) {
console.log("- All files", allFiles);
}

// put all files in three' Cache
for (const fileEntry of allFiles) {
Expand All @@ -222,12 +257,19 @@ async function handleFilesystemEntries(entries) {
// TODO we could also allow dropping of multiple MaterialX files (or folders with them inside)
// and seed the dropdown from that.
// At that point, actually reading files and textures into memory should be deferred until they are actually used.
const rootFile = allFiles[0];
THREE.Cache.add(rootFile.fullPath, await getBufferFromFile(rootFile));
if (allFiles.length > 0)
{
const rootFile = allFiles[0];
THREE.Cache.add(rootFile.fullPath, await getBufferFromFile(rootFile));

if (debugFileHandling) console.log("CACHE", THREE.Cache.files);
if (debugFileHandling) console.log("CACHE", THREE.Cache.files);

loadingCallback(rootFile);
loadingCallback(rootFile);
}
else
{
console.log('No files to add cache.')
}
}

async function readDirectory(directory) {
Expand Down
10 changes: 9 additions & 1 deletion javascript/MaterialXView/source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
import { GammaCorrectionShader } from 'three/examples/jsm/shaders/GammaCorrectionShader.js';

import { Viewer } from './viewer.js'
import { dropHandler, dragOverHandler, setLoadingCallback } from './dropHandling.js';
import { dropHandler, dragOverHandler, setLoadingCallback, setSceneLoadingCallback } from './dropHandling.js';

let renderer, composer, orbitControls;

Expand Down Expand Up @@ -66,6 +66,7 @@ function init()
let geometrySelect = document.getElementById('geometry');
geometrySelect.value = scene.getGeometryURL();
geometrySelect.addEventListener('change', (e) => {
console.log('Change geometry to:', e.target.value);
scene.setGeometryURL(e.target.value);
scene.loadGeometry(viewer, orbitControls);
});
Expand Down Expand Up @@ -155,6 +156,13 @@ function init()
viewer.getScene().setUpdateTransforms();
});

setSceneLoadingCallback(file => {
let glbFileName = file.fullPath || file.name;
console.log('Drop geometry to:', glbFileName);
scene.setGeometryURL(glbFileName);
scene.loadGeometry(viewer, orbitControls);
});

// enable three.js Cache so that dropped files can reference each other
THREE.Cache.enabled = true;
}
Expand Down
19 changes: 19 additions & 0 deletions libraries/nprlib/nprlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
Declarations of standard data types and nodes included in the MaterialX specification.
-->

<!-- ======================================================================== -->
<!-- View-dependent properties -->
<!-- ======================================================================== -->

<geompropdef name="Vworld" type="vector3" geomprop="viewdirection" space="world" />

<!-- ======================================================================== -->
<!-- View-dependent nodes -->
<!-- ======================================================================== -->
Expand All @@ -20,4 +26,17 @@
<output name="out" type="vector3" default="0.0, 0.0, 1.0" />
</nodedef>

<!--
Node: <facingratio>
Return the geometric facing ratio, computed as the dot product between the
view direction and geometric normal.
-->
<nodedef name="ND_facingratio_float" node="facingratio" nodegroup="npr">
<input name="viewdirection" type="vector3" defaultgeomprop="Vworld" />
<input name="normal" type="vector3" defaultgeomprop="Nworld" />
<input name="faceforward" type="boolean" default="true" />
<input name="invert" type="boolean" default="false" />
<output name="out" type="float" default="0.0" />
</nodedef>

</materialx>
48 changes: 48 additions & 0 deletions libraries/nprlib/nprlib_ng.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<materialx version="1.38">
<!--
Copyright Contributors to the MaterialX Project
SPDX-License-Identifier: Apache-2.0
Graph definitions of standard nodes included in the MaterialX specification.
-->

<!-- ======================================================================== -->
<!-- View-dependent nodes -->
<!-- ======================================================================== -->

<!--
Node: <facingratio>
-->
<nodegraph name="NG_facingratio_float" nodedef="ND_facingratio_float">
<dotproduct name="N_dotproduct" type="float">
<input name="in1" type="vector3" interfacename="viewdirection" />
<input name="in2" type="vector3" interfacename="normal" />
</dotproduct>
<multiply name="N_scale" type="float">
<input name="in1" type="float" nodename="N_dotproduct" />
<input name="in2" type="float" value="-1" />
</multiply>
<absval name="N_absval" type="float">
<input name="in" type="float" nodename="N_dotproduct" />
</absval>
<ifequal name="N_facing" type="float">
<input name="value1" type="boolean" interfacename="faceforward" />
<input name="value2" type="boolean" value="true" />
<input name="in1" type="float" nodename="N_absval" />
<input name="in2" type="float" nodename="N_scale" />
</ifequal>
<subtract name="N_invert" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" nodename="N_facing" />
</subtract>
<ifequal name="N_result" type="float">
<input name="value1" type="boolean" interfacename="invert" />
<input name="value2" type="boolean" value="true" />
<input name="in1" type="float" nodename="N_invert" />
<input name="in2" type="float" nodename="N_facing" />
</ifequal>
<output name="out" type="float" nodename="N_result" />
</nodegraph>

</materialx>
7 changes: 0 additions & 7 deletions libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl

This file was deleted.

8 changes: 0 additions & 8 deletions libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl

This file was deleted.

9 changes: 0 additions & 9 deletions libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"

void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result)
void mx_smoothstep_vector2(vec2 val, vec2 low, vec2 high, out vec2 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"

void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, out vec3 result)
void mx_smoothstep_vector3(vec3 val, vec3 low, vec3 high, out vec3 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"

void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result)
void mx_smoothstep_vector4(vec4 val, vec4 low, vec4 high, out vec4 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
Expand Down
Loading

0 comments on commit 5b801bf

Please sign in to comment.