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 3, 2024
2 parents 326d5bc + d4c6f60 commit ec8482c
Show file tree
Hide file tree
Showing 39 changed files with 1,594 additions and 1,001 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ jobs:
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
python: 3.7

- name: MacOS_Xcode_13_Python39
os: macos-12
compiler: xcode
compiler_version: "13.4"
python: 3.9

- name: MacOS_Xcode_14_Python311
os: macos-13
compiler: xcode
compiler_version: "14.3"
python: 3.11

- name: MacOS_Xcode_15_Python312
os: macos-13
compiler: xcode
compiler_version: "15.0"
python: 3.12
test_shaders: ON

- name: iOS_Xcode_15
Expand Down Expand Up @@ -195,14 +195,13 @@ jobs:

- name: Run Clang Format
if: matrix.clang_format == 'ON'
run: find source \( -name *.h -o -name *.cpp -o -name *.mm \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose
run: find source \( -name *.h -o -name *.cpp -o -name *.mm -o -name *.inl \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose

- name: CMake Generate
run: cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON ${{matrix.cmake_config}}

- name: CMake Build
run: cmake --build . --target install --config Release --parallel 2
working-directory: build
run: cmake --build build --target install --config Release --parallel 2

- name: CMake Unit Tests
run: ctest -VV --output-on-failure --build-config Release
Expand Down Expand Up @@ -314,8 +313,7 @@ jobs:

- name: JavaScript CMake Build
if: matrix.build_javascript == 'ON'
run: cmake --build . --target install --config Release --parallel 2
working-directory: javascript/build
run: cmake --build javascript/build --target install --config Release --parallel 2

- name: JavaScript Unit Tests
if: matrix.build_javascript == 'ON'
Expand Down
1,257 changes: 659 additions & 598 deletions javascript/MaterialXTest/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions javascript/MaterialXTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/register": "^7.22.5",
"chai": "^4.3.7",
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@babel/register": "^7.22.15",
"chai": "^4.3.10",
"copyfiles": "^2.4.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
Expand Down
501 changes: 295 additions & 206 deletions javascript/MaterialXView/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions javascript/MaterialXView/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"author": "",
"license": "ISC",
"dependencies": {
"dat.gui": "^0.7.9",
"three": "^0.136.0",
"webpack": "^5.88.2"
"lil-gui": "^0.19.1",
"three": "^0.152.2",
"webpack": "^5.89.0"
},
"devDependencies": {
"copy-webpack-plugin": "^8.1.1",
"html-webpack-plugin": "^5.5.3",
"html-webpack-plugin": "^5.6.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1"
}
Expand Down
60 changes: 8 additions & 52 deletions javascript/MaterialXView/source/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,15 @@ const IMAGE_PATH_SEPARATOR = "/";
*/
export function prepareEnvTexture(texture, capabilities)
{
const rgbaTexture = RGBToRGBA_Float(texture);
rgbaTexture.wrapS = THREE.RepeatWrapping;
rgbaTexture.anisotropy = capabilities.getMaxAnisotropy();
rgbaTexture.minFilter = THREE.LinearMipmapLinearFilter;
rgbaTexture.magFilter = THREE.LinearFilter;
rgbaTexture.generateMipmaps = true;
rgbaTexture.needsUpdate = true;
let newTexture = new THREE.DataTexture(texture.image.data, texture.image.width, texture.image.height, texture.format, texture.type);
newTexture.wrapS = THREE.RepeatWrapping;
newTexture.anisotropy = capabilities.getMaxAnisotropy();
newTexture.minFilter = THREE.LinearMipmapLinearFilter;
newTexture.magFilter = THREE.LinearFilter;
newTexture.generateMipmaps = true;
newTexture.needsUpdate = true;

return rgbaTexture;
}

/**
* Create a new (half)float texture containing an alpha channel with a value of 1 from a RGB (half)float texture.
* @param {THREE.Texture} texture
*/
function RGBToRGBA_Float(texture)
{
const w = texture.image.width;
const h = texture.image.height;
const dataSize = texture.image.data.length;
const stride = dataSize / (w *h);
// No need to convert to RGBA if already 4 channel.
if (stride == 3)
{
const rgbData = texture.image.data;
const length = (rgbData.length / 3) * 4;
let rgbaData;

switch (texture.type)
{
case THREE.FloatType:
rgbaData = new Float32Array(length);
break;
case THREE.HalfFloatType:
rgbaData = new Uint16Array(length);
break;
default:
break;
}

if (rgbaData)
{
for (let i = 0; i < length / 4; i++)
{
rgbaData[(i * 4) + 0] = rgbData[(i * 3) + 0];
rgbaData[(i * 4) + 1] = rgbData[(i * 3) + 1];
rgbaData[(i * 4) + 2] = rgbData[(i * 3) + 2];
rgbaData[(i * 4) + 3] = 1.0;
}
return new THREE.DataTexture(rgbaData, texture.image.width, texture.image.height, THREE.RGBAFormat, texture.type);
}
}
return texture;
return newTexture;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions javascript/MaterialXView/source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function init()
materialsSelect.value = materialFilename;
materialsSelect.addEventListener('change', (e) => {
materialFilename = e.target.value;
viewer.getEditor().clearFolders();
viewer.getEditor().initialize();
viewer.getMaterial().loadMaterials(viewer, materialFilename);
viewer.getEditor().updateProperties(0.9);
viewer.getScene().setUpdateTransforms();
Expand Down Expand Up @@ -83,20 +83,20 @@ function init()
viewer.getEditor().initialize();

const hdrLoader = viewer.getHdrLoader();
const fileLooder = viewer.getFileLoader();
const fileLoader = viewer.getFileLoader();
Promise.all([
new Promise(resolve => hdrLoader.setDataType(THREE.FloatType).load('Lights/san_giuseppe_bridge_split.hdr', resolve)),
new Promise(resolve => fileLooder.load('Lights/san_giuseppe_bridge_split.mtlx', resolve)),
new Promise(resolve => hdrLoader.setDataType(THREE.FloatType).load('Lights/irradiance/san_giuseppe_bridge_split.hdr', resolve)),
new Promise(resolve => hdrLoader.load('Lights/san_giuseppe_bridge_split.hdr', resolve)),
new Promise(resolve => hdrLoader.load('Lights/irradiance/san_giuseppe_bridge_split.hdr', resolve)),
new Promise(resolve => fileLoader.load('Lights/san_giuseppe_bridge_split.mtlx', resolve)),
new Promise(function (resolve) {
MaterialX().then((module) => {
resolve(module);
});
})
]).then(async ([loadedRadianceTexture, loadedLightSetup, loadedIrradianceTexture, mxIn]) =>
]).then(async ([radianceTexture, irradianceTexture, lightRigXml, mxIn]) =>
{
// Initialize viewer + lighting
await viewer.initialize(mxIn, renderer, loadedRadianceTexture, loadedLightSetup, loadedIrradianceTexture);
await viewer.initialize(mxIn, renderer, radianceTexture, irradianceTexture, lightRigXml);

// Load geometry
let scene = viewer.getScene();
Expand All @@ -122,7 +122,7 @@ function init()

setLoadingCallback(file => {
materialFilename = file.fullPath || file.name;
viewer.getEditor().clearFolders();
viewer.getEditor().initialize();
viewer.getMaterial().loadMaterials(viewer, materialFilename);
viewer.getEditor().updateProperties(0.9);
viewer.getScene().setUpdateTransforms();
Expand Down
Loading

0 comments on commit ec8482c

Please sign in to comment.