diff --git a/javascript/MaterialXTest/customBindings.spec.js b/javascript/MaterialXTest/customBindings.spec.js
index b95ab11358..bd306211d5 100644
--- a/javascript/MaterialXTest/customBindings.spec.js
+++ b/javascript/MaterialXTest/customBindings.spec.js
@@ -120,7 +120,7 @@ describe('Custom Bindings', () =>
await mx.readFromXmlFile(doc, filename, examplesPath);
const sourceUris = doc.getReferencedSourceUris();
expect(sourceUris).to.be.instanceof(Array);
- expect(sourceUris.length).to.equal(3);
+ expect(sourceUris.length).to.equal(4);
expect(sourceUris[0]).to.be.a('string');
expect(sourceUris.includes('standard_surface_brass_tiled.mtlx')).to.be.true;
doc.delete();
diff --git a/javascript/MaterialXView/source/viewer.js b/javascript/MaterialXView/source/viewer.js
index 89dcddca1e..296c251085 100644
--- a/javascript/MaterialXView/source/viewer.js
+++ b/javascript/MaterialXView/source/viewer.js
@@ -997,7 +997,6 @@ export class Material
matTitle.classList.remove('peditor_material_assigned');
let img = matTitle.getElementsByTagName('img')[0];
img.src = 'public/shader_ball.svg';
- //matTitle.classList.remove('peditor_material_unassigned');
}
}
}
@@ -1007,34 +1006,45 @@ export class Material
// Prevent the event from being passed to parent folder
event.stopPropagation();
+ let materialNameList = new Set()
for (let i = 0; i < materials.length; ++i)
{
let matassign = materials[i];
// Need to use path vs name to get a unique key.
let materialName = matassign.getMaterial().getNamePath();
+ if (materialNameList.has(materialName))
+ {
+ continue;
+ }
+
var matUI = matassign.getMaterialUI();
- let matTitle = matUI.domElement.getElementsByClassName('title')[0];
- let img = matTitle.getElementsByTagName('img')[0];
- if (materialName == elemPath)
+ if (matUI)
{
- if (this._soloMaterial == elemPath)
+ materialNameList.add(materialName);
+
+ let matTitle = matUI.domElement.getElementsByClassName('title')[0];
+ let img = matTitle.getElementsByTagName('img')[0];
+ if (materialName == elemPath)
{
- img.src = 'public/shader_ball.svg';
- matTitle.classList.remove('peditor_material_assigned');
- this._soloMaterial = "";
+ if (this._soloMaterial == elemPath)
+ {
+ img.src = 'public/shader_ball.svg';
+ matTitle.classList.remove('peditor_material_assigned');
+ this._soloMaterial = "";
+ }
+ else
+ {
+ img.src = 'public/shader_ball2.svg';
+ matTitle.classList.add('peditor_material_assigned');
+ this._soloMaterial = elemPath;
+ }
}
else
{
- img.src = 'public/shader_ball2.svg';
- matTitle.classList.add('peditor_material_assigned');
- this._soloMaterial = elemPath;
+ img.src = 'public/shader_ball.svg';
+ matTitle.classList.remove('peditor_material_assigned');
}
}
- else
- {
- img.src = 'public/shader_ball.svg';
- matTitle.classList.remove('peditor_material_assigned');
- }
}
viewer.getMaterial().updateMaterialAssignments(viewer, this._soloMaterial);
}
@@ -1056,22 +1066,27 @@ export class Material
const elemPath = elem.getNamePath();
// Create and cache associated UI
- var matUI = gui.addFolder(elemPath);
+ let matUI = gui.addFolder(elemPath);
+ console.log('Set material UI for: ', elemPath, matUI);
matassign.setMaterialUI(matUI);
- let matTitle = matUI.domElement.getElementsByClassName('title')[0];
- // Add a icon to the title to allow for assigning the material to geometry
- // Clicking on the icon will "solo" the material to the geometry.
- // Clicking on the title will open/close the material folder.
- matTitle.innerHTML = "
" + elem.getNamePath();
- let img = matTitle.getElementsByTagName('img')[0];
- if (img)
+ let matTitle = null
+ if (matUI && matUI.domElement)
{
- // Add event listener to icon to call updateSoloMaterial function
- img.addEventListener('click', function (event)
+ matTitle = matUI.domElement.getElementsByClassName('title')[0];
+ // Add a icon to the title to allow for assigning the material to geometry
+ // Clicking on the icon will "solo" the material to the geometry.
+ // Clicking on the title will open/close the material folder.
+ matTitle.innerHTML = "
" + elem.getNamePath();
+ let img = matTitle.getElementsByTagName('img')[0];
+ if (img)
{
- Material.updateSoloMaterial(viewer, elemPath, materials, event);
- });
+ // Add event listener to icon to call updateSoloMaterial function
+ img.addEventListener('click', function (event)
+ {
+ Material.updateSoloMaterial(viewer, elemPath, materials, event);
+ });
+ }
}
if (closeUI)
diff --git a/resources/Geometry/usdshaderball.glb b/resources/Geometry/usdshaderball.glb
new file mode 100644
index 0000000000..10e9c913b0
Binary files /dev/null and b/resources/Geometry/usdshaderball.glb differ
diff --git a/resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx b/resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx
index 510f1c27fd..c84f4afcdb 100644
--- a/resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx
+++ b/resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx
@@ -2,8 +2,11 @@
+
+
+
diff --git a/resources/Materials/Examples/StandardSurface/standard_surface_look_glass.mtlx b/resources/Materials/Examples/StandardSurface/standard_surface_look_glass.mtlx
new file mode 100644
index 0000000000..2cdbfd3b38
--- /dev/null
+++ b/resources/Materials/Examples/StandardSurface/standard_surface_look_glass.mtlx
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/MaterialXView/Main.cpp b/source/MaterialXView/Main.cpp
index bedcc596b6..738ea6bc63 100644
--- a/source/MaterialXView/Main.cpp
+++ b/source/MaterialXView/Main.cpp
@@ -47,6 +47,7 @@ const std::string options =
" --remap [TOKEN1:TOKEN2] Specify the remapping from one token to another when MaterialX document is loaded\n"
" --skip [NAME] Specify to skip elements matching the given name attribute\n"
" --terminator [STRING] Specify to enforce the given terminator string for file prefixes\n"
+ " --transmissionMethod [STRING] Specify the method used to render transmission. Options are: 'opacity', 'refraction'. Default is refraction\n"
" --help Display the complete list of command-line options\n";
template void parseToken(std::string token, std::string type, T& res)
@@ -75,7 +76,7 @@ int main(int argc, char* const argv[])
}
std::string materialFilename = "resources/Materials/Examples/StandardSurface/standard_surface_default.mtlx";
- std::string meshFilename = "resources/Geometry/shaderball.glb";
+ std::string meshFilename = "resources/Geometry/usdshaderball.glb";
std::string envRadianceFilename = "resources/Lights/san_giuseppe_bridge_split.hdr";
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();
mx::FilePathVec libraryFolders;
@@ -88,6 +89,7 @@ int main(int argc, char* const argv[])
mx::Vector3 cameraTarget;
float cameraViewAngle(DEFAULT_CAMERA_VIEW_ANGLE);
float cameraZoom(DEFAULT_CAMERA_ZOOM);
+ mx::HwTransmissionRenderMethod transmissionMethod = mx::TRANSMISSION_REFRACTION;
mx::HwSpecularEnvironmentMethod specularEnvironmentMethod = mx::SPECULAR_ENVIRONMENT_FIS;
int envSampleCount = mx::DEFAULT_ENV_SAMPLE_COUNT;
float envLightIntensity = 1.0f;
@@ -254,6 +256,24 @@ int main(int argc, char* const argv[])
{
modifiers.filePrefixTerminator = nextToken;
}
+ else if (token == "--transmissionMethod")
+ {
+ const std::string method = nextToken;
+ if (method == "opacity")
+ {
+ transmissionMethod = mx::TRANSMISSION_OPACITY;
+ }
+ else if (method == "refraction")
+ {
+ transmissionMethod = mx::TRANSMISSION_REFRACTION;
+ }
+ else
+ {
+ std::cout << "Unrecognized transmission method: " << method << std::endl;
+ std::cout << "Supported methods are: 'opacity', 'refraction'" << std::endl;
+ }
+ }
+
else if (token == "--help")
{
std::cout << " MaterialXView version " << mx::getVersionString() << std::endl;
@@ -299,6 +319,7 @@ int main(int argc, char* const argv[])
viewer->setCameraViewAngle(cameraViewAngle);
viewer->setCameraZoom(cameraZoom);
viewer->setSpecularEnvironmentMethod(specularEnvironmentMethod);
+ viewer->setTransmissionRenderMethod(transmissionMethod);
viewer->setEnvSampleCount(envSampleCount);
viewer->setEnvLightIntensity(envLightIntensity);
viewer->setLightRotation(lightRotation);
diff --git a/source/MaterialXView/Viewer.h b/source/MaterialXView/Viewer.h
index 515b8a75d8..feb157b39d 100644
--- a/source/MaterialXView/Viewer.h
+++ b/source/MaterialXView/Viewer.h
@@ -102,6 +102,12 @@ class Viewer : public ng::Screen
_genContext.getOptions().hwSpecularEnvironmentMethod = method;
}
+ // Set the method for transmission rendering.
+ void setTransmissionRenderMethod(mx::HwTransmissionRenderMethod method)
+ {
+ _genContext.getOptions().hwTransmissionRenderMethod = method;
+ }
+
// Set the number of environment samples.
void setEnvSampleCount(int count)
{