Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Du <42884035+GregoryD2017@users.noreply.github.com>
  • Loading branch information
GregoryD2017 committed Dec 10, 2023
2 parents aad650e + cd82ea5 commit 6222d42
Show file tree
Hide file tree
Showing 68 changed files with 1,291 additions and 1,153 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,252 changes: 656 additions & 596 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.5",
"@babel/preset-env": "^7.23.5",
"@babel/register": "^7.22.15",
"chai": "^4.3.10",
"copyfiles": "^2.4.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
Expand Down
466 changes: 273 additions & 193 deletions javascript/MaterialXView/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions javascript/MaterialXView/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"dependencies": {
"dat.gui": "^0.7.9",
"three": "^0.136.0",
"webpack": "^5.88.2"
"webpack": "^5.89.0"
},
"devDependencies": {
"copy-webpack-plugin": "^8.1.1",
"html-webpack-plugin": "^5.5.3",
"html-webpack-plugin": "^5.5.4",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1"
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXCore/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ InterfaceElementPtr NodeDef::getImplementation(const string& target) const
}
}
}

// Then search for a generic match.
for (InterfaceElementPtr interface : interfaces)
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXFormat/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ FileSearchPath getDefaultDataSearchPath()
}
currentPath = currentPath.getParentPath();
}
return FileSearchPath();
return FileSearchPath();
}

MATERIALX_NAMESPACE_END
2 changes: 1 addition & 1 deletion source/MaterialXFormat/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ MX_FORMAT_API FileSearchPath getSourceSearchPath(ConstDocumentPtr doc);

/// Return a file search path to the default data library folder.
/// The module path and all parent paths are examined to until either there is
/// no parent or the library folder is found.
/// no parent or the library folder is found.
MX_FORMAT_API FileSearchPath getDefaultDataSearchPath();

MATERIALX_NAMESPACE_END
Expand Down
20 changes: 10 additions & 10 deletions source/MaterialXGenGlsl/GlslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ GlslShaderGenerator::GlslShaderGenerator() :
//

StringVec elementNames;

// <!-- <switch> -->
elementNames = {
// <!-- 'which' type : float -->
"IM_switch_float_" + GlslShaderGenerator::TARGET,
"IM_switch_color3_" + GlslShaderGenerator::TARGET,
"IM_switch_color4_" + GlslShaderGenerator::TARGET,
"IM_switch_float_" + GlslShaderGenerator::TARGET,
"IM_switch_color3_" + GlslShaderGenerator::TARGET,
"IM_switch_color4_" + GlslShaderGenerator::TARGET,
"IM_switch_vector2_" + GlslShaderGenerator::TARGET,
"IM_switch_vector3_" + GlslShaderGenerator::TARGET,
"IM_switch_vector4_" + GlslShaderGenerator::TARGET,

// <!-- 'which' type : integer -->
"IM_switch_floatI_" + GlslShaderGenerator::TARGET,
"IM_switch_color3I_" + GlslShaderGenerator::TARGET,
Expand All @@ -85,39 +85,39 @@ GlslShaderGenerator::GlslShaderGenerator() :
"IM_swizzle_float_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_float_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_float_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : color3 -->
"IM_swizzle_color3_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : color4 -->
"IM_swizzle_color4_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector2 -->
"IM_swizzle_vector2_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector3 -->
"IM_swizzle_vector3_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector4 -->
"IM_swizzle_vector4_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector4_color3_" + GlslShaderGenerator::TARGET,
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXGenMdl/MdlShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, G
{
emitLine("float3 displacement__ = " + result + ".geometry.displacement", stage);
emitLine("color finalOutput__ = mk_color3("
"r: math::dot(displacement__, state::texture_tangent_u(0)),"
"g: math::dot(displacement__, state::texture_tangent_v(0)),"
"b: math::dot(displacement__, state::normal()))", stage);
"r: math::dot(displacement__, state::texture_tangent_u(0)),"
"g: math::dot(displacement__, state::texture_tangent_v(0)),"
"b: math::dot(displacement__, state::normal()))", stage);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/MdlSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MdlFilenameTypeSyntax : public ScalarTypeSyntax
// assuming it ends with a slash ...
if (outputValue.back() == '/')
{
return getDefaultValue(true);
return getDefaultValue(true);
}
// ... or the last segment does not have an extension suffix
size_t idx_s = outputValue.find_last_of('/');
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/Nodes/ClosureCompoundNodeMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void ClosureCompoundNodeMdl::emitFunctionDefinition(const ShaderNode& node, GenC
{
if (!outputSocket->getConnection())
continue;

const ShaderNode* upstream = outputSocket->getConnection()->getNode();
const bool isMaterialExpr = (upstream->hasClassification(ShaderNode::Classification::CLOSURE) ||
upstream->hasClassification(ShaderNode::Classification::SHADER));
Expand Down
24 changes: 12 additions & 12 deletions source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ const string& MixBsdfNodeMdl::getOperatorName(size_t index) const
{
switch (index)
{
case 0:
return StringConstantsMdl::FG;
case 1:
return StringConstantsMdl::BG;
default:
return StringConstantsMdl::EMPTY;
case 0:
return StringConstantsMdl::FG;
case 1:
return StringConstantsMdl::BG;
default:
return StringConstantsMdl::EMPTY;
}
}

Expand All @@ -386,12 +386,12 @@ const string& AddOrMultiplyBsdfNodeMdl::getOperatorName(size_t index) const
{
switch (index)
{
case 0:
return StringConstantsMdl::IN1;
case 1:
return StringConstantsMdl::IN2;
default:
return StringConstantsMdl::EMPTY;
case 0:
return StringConstantsMdl::IN1;
case 1:
return StringConstantsMdl::IN2;
default:
return StringConstantsMdl::EMPTY;
}
}

Expand Down
16 changes: 8 additions & 8 deletions source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class MX_GENMDL_API StringConstantsMdl

public:
/// String constants
static const string TOP; ///< layer parameter name of the top component
static const string TOP; ///< layer parameter name of the top component
static const string BASE; ///< layer parameter name of the base component
static const string FG; ///< parameter of the mix node
static const string BG; ///< parameter of the mix node
static const string IN1; ///< parameter of the add and multiply nodes
static const string IN2; ///< parameter of the add and multiply nodes
static const string FG; ///< parameter of the mix node
static const string BG; ///< parameter of the mix node
static const string IN1; ///< parameter of the add and multiply nodes
static const string IN2; ///< parameter of the add and multiply nodes

static const string THICKNESS; ///< thickness parameter name of the thin_film_bsdf
static const string IOR; ///< ior parameter name of the thin_film_bsdf
static const string IOR; ///< ior parameter name of the thin_film_bsdf

static const string THIN_FILM_THICKNESS; ///< helper parameter name for transporting thickness
static const string THIN_FILM_IOR; ///< helper parameter name for transporting ior
static const string THIN_FILM_IOR; ///< helper parameter name for transporting ior

static const string EMPTY; ///< the empty string ""
};
Expand All @@ -41,7 +41,7 @@ class MX_GENMDL_API StringConstantsMdl
/// thin_film_bsdf through layers and mixers, etc., to the elemental bsdfs that support thin film.
/// Because thin-film can not be layered on any BSDF in MDL, we try to push down the parameters to
/// the nodes that support thin-film.
template<typename TBase> class CarryThinFilmParameters : public TBase
template <typename TBase> class CarryThinFilmParameters : public TBase
{
public:
/// Add the thin film inputs for transporting the parameter.
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMsl/MslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ void MslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& co
emitLightData(context, stage);
}
}

bool needsLightBuffer = lighting && context.getOptions().hwMaxActiveLightSources > 0;

emitMathMatrixScalarMathOperators(context, stage);
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenOsl/OslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void OslShaderGenerator::emitShaderInputs(const VariableBlock& inputs, ShaderSta
// which is a struct containing a file string and a colorspace string.
// For the published shader interface we here split this into two separate inputs,
// which gives a nicer shader interface with widget metadata on each input.

ValuePtr value = input->getValue();
const string valueStr = value ? value->getValueString() : EMPTY_STRING;

Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenShader/HwShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element
if (geomprop)
{
// A default geomprop was assigned to this graph input.
// For all internal connections to this input, break the connection
// For all internal connections to this input, break the connection
// and assign a geomprop node that generates this data.
// Note: If a geomprop node exists already it is reused,
// Note: If a geomprop node exists already it is reused,
// so only a single node per geometry type is created.
ShaderInputVec connections = socket->getConnections();
for (auto connection : connections)
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/Nodes/HwTransformNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const string HwTransformNode::WORLD = "world";

void HwTransformNode::createVariables(const ShaderNode& node, GenContext&, Shader& shader) const
{
const string toSpace = getToSpace(node);
const string toSpace = getToSpace(node);
const string fromSpace = getFromSpace(node);
const string& matrix = getMatrix(fromSpace, toSpace);
if (!matrix.empty())
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void ShaderGenerator::registerImplementation(const string& name, CreatorFunction

void ShaderGenerator::registerImplementation(const StringVec& nameVec, CreatorFunction<ShaderNodeImpl> creator)
{
for(const string& name : nameVec)
for (const string& name : nameVec)
{
_implFactory.registerClass(name, creator);
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class MX_GENSHADER_API ShaderGenerator

/// Register a shader node implementation for a given implementation element name
void registerImplementation(const string& name, CreatorFunction<ShaderNodeImpl> creator);

/// Register a shader node implementation for a given set of implementation element names
void registerImplementation(const StringVec& nameVec, CreatorFunction<ShaderNodeImpl> creator);

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ ShaderNodePtr ShaderNode::create(const ShaderGraph* parent, const string& name,
else if (nodeDef.getNodeString() == CONSTANT)
{
newNode->_classification = Classification::TEXTURE | Classification::CONSTANT;
}
}
else if (nodeDef.getNodeString() == DOT)
{
newNode->_classification = Classification::TEXTURE | Classification::DOT;
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenShader/ShaderStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ ShaderPort* VariableBlock::add(const TypeDesc* type, const string& name, ValuePt
else if (type != it->second->getType())
{
throw ExceptionShaderGenError("Trying to add shader port '" + name + "' with type '" +
type->getName() + "', but existing shader port with type '" +
it->second->getType()->getName() + "' was found");
type->getName() + "', but existing shader port with type '" +
it->second->getType()->getName() + "' was found");
}
return it->second.get();
}
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXGraphEditor/FileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class FileDialog
public:
enum Flags
{
SelectDirectory = 1 << 0, // select directory instead of regular file
EnterNewFilename = 1 << 1, // allow user to enter new filename when selecting regular file
NoTitleBar = 1 << 2, // hide window title bar
SelectDirectory = 1 << 0, // select directory instead of regular file
EnterNewFilename = 1 << 1, // allow user to enter new filename when selecting regular file
NoTitleBar = 1 << 2, // hide window title bar
};

public:
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,6 @@ void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId)
break;
}
}

}

// Since we accepted new link, lets add one to our list of links.
Expand Down Expand Up @@ -3744,6 +3743,7 @@ void Graph::addNodePopup(UiPinPtr originPin)
ImGui::SetKeyboardFocusHere();
}
ImGui::InputText("##input", input, sizeof(input));

std::string filterString(input);
if (!filterString.empty()) {
// Allow spaces to be used in the input filter entry
Expand Down
Loading

0 comments on commit 6222d42

Please sign in to comment.