From e3ef2d37497d552e3801241733f6ce3df4a58156 Mon Sep 17 00:00:00 2001 From: Lee Kerley Date: Fri, 10 Oct 2025 17:01:35 -0700 Subject: [PATCH 1/2] change include from <> to "" for main header enable include sorting with priority rules enable aligning assignments - this really helps with HwConstant.h/cpp --- .clang-format | 19 ++++++++++++++++++- source/MaterialXGenHw/HwConstants.cpp | 2 +- source/MaterialXGenHw/HwImplementation.cpp | 2 +- source/MaterialXGenHw/HwShaderGenerator.cpp | 2 +- .../MaterialXGenHw/Nodes/HwBitangentNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwFrameNode.cpp | 2 +- .../MaterialXGenHw/Nodes/HwGeomColorNode.cpp | 2 +- .../Nodes/HwGeomPropValueNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwImageNode.cpp | 2 +- .../Nodes/HwLightCompoundNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwLightNode.cpp | 2 +- .../Nodes/HwLightSamplerNode.cpp | 2 +- .../Nodes/HwLightShaderNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwNormalNode.cpp | 2 +- .../MaterialXGenHw/Nodes/HwNumLightsNode.cpp | 2 +- .../MaterialXGenHw/Nodes/HwPositionNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwTangentNode.cpp | 2 +- .../MaterialXGenHw/Nodes/HwTexCoordNode.cpp | 2 +- source/MaterialXGenHw/Nodes/HwTimeNode.cpp | 2 +- .../MaterialXGenHw/Nodes/HwTransformNode.cpp | 2 +- .../Nodes/HwViewDirectionNode.cpp | 2 +- 22 files changed, 39 insertions(+), 22 deletions(-) diff --git a/.clang-format b/.clang-format index 14ee8eda71..f7a077c093 100644 --- a/.clang-format +++ b/.clang-format @@ -12,7 +12,24 @@ IndentPPDirectives: BeforeHash IndentWidth: 4 LambdaBodyIndentation: OuterScope PointerAlignment: Left -SortIncludes: false SpaceAfterCStyleCast: true SpaceInEmptyBlock: true UseTab: Never + +AlignConsecutiveAssignments: AcrossEmptyLines + +SortIncludes: true +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^<(MaterialXGenGlsl|MaterialXGenMdl|MaterialXGenMsl|MaterialXGenOsl|MaterialXGenHw)/' + Priority: 50 + - Regex: '^ +#include "HwConstants.h" #include MATERIALX_NAMESPACE_BEGIN diff --git a/source/MaterialXGenHw/HwImplementation.cpp b/source/MaterialXGenHw/HwImplementation.cpp index 8c572eb0b5..e2526ddf4b 100644 --- a/source/MaterialXGenHw/HwImplementation.cpp +++ b/source/MaterialXGenHw/HwImplementation.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwImplementation.h" #include MATERIALX_NAMESPACE_BEGIN diff --git a/source/MaterialXGenHw/HwShaderGenerator.cpp b/source/MaterialXGenHw/HwShaderGenerator.cpp index 4024a1999b..5df82ea7bf 100644 --- a/source/MaterialXGenHw/HwShaderGenerator.cpp +++ b/source/MaterialXGenHw/HwShaderGenerator.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwShaderGenerator.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp b/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp index 4d3e43e39c..59e57973ce 100644 --- a/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwBitangentNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwFrameNode.cpp b/source/MaterialXGenHw/Nodes/HwFrameNode.cpp index e4bacddaa7..13de87f408 100644 --- a/source/MaterialXGenHw/Nodes/HwFrameNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwFrameNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwFrameNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp b/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp index c36920e550..0393f067d2 100644 --- a/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwGeomColorNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp b/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp index 433239f4b0..fc043ca6a6 100644 --- a/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwGeomPropValueNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwImageNode.cpp b/source/MaterialXGenHw/Nodes/HwImageNode.cpp index a926eef1c2..ec502e1f1a 100644 --- a/source/MaterialXGenHw/Nodes/HwImageNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwImageNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwImageNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp b/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp index bf86c31702..a5c7f6fe59 100644 --- a/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwLightCompoundNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwLightNode.cpp b/source/MaterialXGenHw/Nodes/HwLightNode.cpp index c4e45d39e4..a241739080 100644 --- a/source/MaterialXGenHw/Nodes/HwLightNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwLightNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp b/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp index 6275a35b74..ba9a5abf7a 100644 --- a/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwLightSamplerNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp b/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp index 4f40f4f11f..9a4f9044eb 100644 --- a/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwLightShaderNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwNormalNode.cpp b/source/MaterialXGenHw/Nodes/HwNormalNode.cpp index fcc9666a48..8d55399ca6 100644 --- a/source/MaterialXGenHw/Nodes/HwNormalNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwNormalNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwNormalNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp b/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp index fc6f73508d..133b3bd883 100644 --- a/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwNumLightsNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwPositionNode.cpp b/source/MaterialXGenHw/Nodes/HwPositionNode.cpp index da4310dc90..09b76f951e 100644 --- a/source/MaterialXGenHw/Nodes/HwPositionNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwPositionNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwPositionNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp b/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp index c727acfdb7..1cfe766cd3 100644 --- a/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwSurfaceNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwTangentNode.cpp b/source/MaterialXGenHw/Nodes/HwTangentNode.cpp index c90ba6712f..8930f4a2cc 100644 --- a/source/MaterialXGenHw/Nodes/HwTangentNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTangentNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwTangentNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp b/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp index 996928e395..6544835ac0 100644 --- a/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwTexCoordNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwTimeNode.cpp b/source/MaterialXGenHw/Nodes/HwTimeNode.cpp index 503fce3830..3f75fb8df1 100644 --- a/source/MaterialXGenHw/Nodes/HwTimeNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTimeNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwTimeNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwTransformNode.cpp b/source/MaterialXGenHw/Nodes/HwTransformNode.cpp index 59a536895d..6ac052bbad 100644 --- a/source/MaterialXGenHw/Nodes/HwTransformNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTransformNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwTransformNode.h" #include #include diff --git a/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp b/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp index c2192566f5..adbc213146 100644 --- a/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "HwViewDirectionNode.h" #include #include From f960b73285e52de1006f149bf6a749002c3a87aa Mon Sep 17 00:00:00 2001 From: Lee Kerley Date: Mon, 13 Oct 2025 21:12:55 -0700 Subject: [PATCH 2/2] Apply new clang-format rules to MaterialXGenHw module. --- source/MaterialXGenHw/HwConstants.cpp | 1 + source/MaterialXGenHw/HwImplementation.cpp | 5 +- source/MaterialXGenHw/HwImplementation.h | 4 +- source/MaterialXGenHw/HwShaderGenerator.cpp | 138 +++++++++--------- .../MaterialXGenHw/Nodes/HwBitangentNode.cpp | 17 ++- source/MaterialXGenHw/Nodes/HwFrameNode.cpp | 1 + .../MaterialXGenHw/Nodes/HwGeomColorNode.cpp | 23 +-- .../Nodes/HwGeomPropValueNode.cpp | 21 +-- source/MaterialXGenHw/Nodes/HwImageNode.cpp | 2 +- .../Nodes/HwLightCompoundNode.cpp | 4 +- source/MaterialXGenHw/Nodes/HwLightNode.cpp | 5 +- .../Nodes/HwLightSamplerNode.cpp | 1 + .../Nodes/HwLightShaderNode.cpp | 1 + source/MaterialXGenHw/Nodes/HwNormalNode.cpp | 11 +- .../MaterialXGenHw/Nodes/HwNumLightsNode.cpp | 3 +- .../MaterialXGenHw/Nodes/HwPositionNode.cpp | 11 +- source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp | 17 ++- source/MaterialXGenHw/Nodes/HwTangentNode.cpp | 11 +- .../MaterialXGenHw/Nodes/HwTexCoordNode.cpp | 21 +-- source/MaterialXGenHw/Nodes/HwTexCoordNode.h | 1 + source/MaterialXGenHw/Nodes/HwTimeNode.cpp | 1 + .../MaterialXGenHw/Nodes/HwTransformNode.cpp | 23 +-- source/MaterialXGenHw/Nodes/HwTransformNode.h | 4 +- .../Nodes/HwViewDirectionNode.cpp | 13 +- 24 files changed, 180 insertions(+), 159 deletions(-) diff --git a/source/MaterialXGenHw/HwConstants.cpp b/source/MaterialXGenHw/HwConstants.cpp index 81235ee37a..d69f2de987 100644 --- a/source/MaterialXGenHw/HwConstants.cpp +++ b/source/MaterialXGenHw/HwConstants.cpp @@ -4,6 +4,7 @@ // #include "HwConstants.h" + #include MATERIALX_NAMESPACE_BEGIN diff --git a/source/MaterialXGenHw/HwImplementation.cpp b/source/MaterialXGenHw/HwImplementation.cpp index e2526ddf4b..0c56b985c3 100644 --- a/source/MaterialXGenHw/HwImplementation.cpp +++ b/source/MaterialXGenHw/HwImplementation.cpp @@ -4,12 +4,13 @@ // #include "HwImplementation.h" + #include MATERIALX_NAMESPACE_BEGIN -const string HwImplementation::SPACE = "space"; -const string HwImplementation::INDEX = "index"; +const string HwImplementation::SPACE = "space"; +const string HwImplementation::INDEX = "index"; const string HwImplementation::GEOMPROP = "geomprop"; namespace diff --git a/source/MaterialXGenHw/HwImplementation.h b/source/MaterialXGenHw/HwImplementation.h index 66c20f7c18..3289ade1d1 100644 --- a/source/MaterialXGenHw/HwImplementation.h +++ b/source/MaterialXGenHw/HwImplementation.h @@ -29,9 +29,9 @@ class MX_GENHW_API HwImplementation : public ShaderNodeImpl // The order must match the order given for the space enum string in stdlib. enum Space { - MODEL_SPACE = 0, + MODEL_SPACE = 0, OBJECT_SPACE = 1, - WORLD_SPACE = 2 + WORLD_SPACE = 2 }; /// Internal string constants diff --git a/source/MaterialXGenHw/HwShaderGenerator.cpp b/source/MaterialXGenHw/HwShaderGenerator.cpp index 5df82ea7bf..ca4e919632 100644 --- a/source/MaterialXGenHw/HwShaderGenerator.cpp +++ b/source/MaterialXGenHw/HwShaderGenerator.cpp @@ -8,9 +8,11 @@ #include #include #include -#include + #include +#include #include + #include #include @@ -25,73 +27,73 @@ HwShaderGenerator::HwShaderGenerator(TypeSystemPtr typeSystem, SyntaxPtr syntax) { // Assign default identifiers names for all tokens. // Derived generators can override these names. - _tokenSubstitutions[HW::T_IN_POSITION] = HW::IN_POSITION; - _tokenSubstitutions[HW::T_IN_NORMAL] = HW::IN_NORMAL; - _tokenSubstitutions[HW::T_IN_TANGENT] = HW::IN_TANGENT; - _tokenSubstitutions[HW::T_IN_BITANGENT] = HW::IN_BITANGENT; - _tokenSubstitutions[HW::T_IN_TEXCOORD] = HW::IN_TEXCOORD; - _tokenSubstitutions[HW::T_IN_GEOMPROP] = HW::IN_GEOMPROP; - _tokenSubstitutions[HW::T_IN_COLOR] = HW::IN_COLOR; - _tokenSubstitutions[HW::T_POSITION_WORLD] = HW::POSITION_WORLD; - _tokenSubstitutions[HW::T_NORMAL_WORLD] = HW::NORMAL_WORLD; - _tokenSubstitutions[HW::T_TANGENT_WORLD] = HW::TANGENT_WORLD; - _tokenSubstitutions[HW::T_BITANGENT_WORLD] = HW::BITANGENT_WORLD; - _tokenSubstitutions[HW::T_POSITION_OBJECT] = HW::POSITION_OBJECT; - _tokenSubstitutions[HW::T_NORMAL_OBJECT] = HW::NORMAL_OBJECT; - _tokenSubstitutions[HW::T_TANGENT_OBJECT] = HW::TANGENT_OBJECT; - _tokenSubstitutions[HW::T_BITANGENT_OBJECT] = HW::BITANGENT_OBJECT; - _tokenSubstitutions[HW::T_TEXCOORD] = HW::TEXCOORD; - _tokenSubstitutions[HW::T_COLOR] = HW::COLOR; - _tokenSubstitutions[HW::T_WORLD_MATRIX] = HW::WORLD_MATRIX; - _tokenSubstitutions[HW::T_WORLD_INVERSE_MATRIX] = HW::WORLD_INVERSE_MATRIX; - _tokenSubstitutions[HW::T_WORLD_TRANSPOSE_MATRIX] = HW::WORLD_TRANSPOSE_MATRIX; + _tokenSubstitutions[HW::T_IN_POSITION] = HW::IN_POSITION; + _tokenSubstitutions[HW::T_IN_NORMAL] = HW::IN_NORMAL; + _tokenSubstitutions[HW::T_IN_TANGENT] = HW::IN_TANGENT; + _tokenSubstitutions[HW::T_IN_BITANGENT] = HW::IN_BITANGENT; + _tokenSubstitutions[HW::T_IN_TEXCOORD] = HW::IN_TEXCOORD; + _tokenSubstitutions[HW::T_IN_GEOMPROP] = HW::IN_GEOMPROP; + _tokenSubstitutions[HW::T_IN_COLOR] = HW::IN_COLOR; + _tokenSubstitutions[HW::T_POSITION_WORLD] = HW::POSITION_WORLD; + _tokenSubstitutions[HW::T_NORMAL_WORLD] = HW::NORMAL_WORLD; + _tokenSubstitutions[HW::T_TANGENT_WORLD] = HW::TANGENT_WORLD; + _tokenSubstitutions[HW::T_BITANGENT_WORLD] = HW::BITANGENT_WORLD; + _tokenSubstitutions[HW::T_POSITION_OBJECT] = HW::POSITION_OBJECT; + _tokenSubstitutions[HW::T_NORMAL_OBJECT] = HW::NORMAL_OBJECT; + _tokenSubstitutions[HW::T_TANGENT_OBJECT] = HW::TANGENT_OBJECT; + _tokenSubstitutions[HW::T_BITANGENT_OBJECT] = HW::BITANGENT_OBJECT; + _tokenSubstitutions[HW::T_TEXCOORD] = HW::TEXCOORD; + _tokenSubstitutions[HW::T_COLOR] = HW::COLOR; + _tokenSubstitutions[HW::T_WORLD_MATRIX] = HW::WORLD_MATRIX; + _tokenSubstitutions[HW::T_WORLD_INVERSE_MATRIX] = HW::WORLD_INVERSE_MATRIX; + _tokenSubstitutions[HW::T_WORLD_TRANSPOSE_MATRIX] = HW::WORLD_TRANSPOSE_MATRIX; _tokenSubstitutions[HW::T_WORLD_INVERSE_TRANSPOSE_MATRIX] = HW::WORLD_INVERSE_TRANSPOSE_MATRIX; - _tokenSubstitutions[HW::T_VIEW_MATRIX] = HW::VIEW_MATRIX; - _tokenSubstitutions[HW::T_VIEW_INVERSE_MATRIX] = HW::VIEW_INVERSE_MATRIX; - _tokenSubstitutions[HW::T_VIEW_TRANSPOSE_MATRIX] = HW::VIEW_TRANSPOSE_MATRIX; - _tokenSubstitutions[HW::T_VIEW_INVERSE_TRANSPOSE_MATRIX] = HW::VIEW_INVERSE_TRANSPOSE_MATRIX; - _tokenSubstitutions[HW::T_PROJ_MATRIX] = HW::PROJ_MATRIX; - _tokenSubstitutions[HW::T_PROJ_INVERSE_MATRIX] = HW::PROJ_INVERSE_MATRIX; - _tokenSubstitutions[HW::T_PROJ_TRANSPOSE_MATRIX] = HW::PROJ_TRANSPOSE_MATRIX; - _tokenSubstitutions[HW::T_PROJ_INVERSE_TRANSPOSE_MATRIX] = HW::PROJ_INVERSE_TRANSPOSE_MATRIX; - _tokenSubstitutions[HW::T_WORLD_VIEW_MATRIX] = HW::WORLD_VIEW_MATRIX; - _tokenSubstitutions[HW::T_VIEW_PROJECTION_MATRIX] = HW::VIEW_PROJECTION_MATRIX; - _tokenSubstitutions[HW::T_WORLD_VIEW_PROJECTION_MATRIX] = HW::WORLD_VIEW_PROJECTION_MATRIX; - _tokenSubstitutions[HW::T_VIEW_POSITION] = HW::VIEW_POSITION; - _tokenSubstitutions[HW::T_VIEW_DIRECTION] = HW::VIEW_DIRECTION; - _tokenSubstitutions[HW::T_FRAME] = HW::FRAME; - _tokenSubstitutions[HW::T_TIME] = HW::TIME; - _tokenSubstitutions[HW::T_GEOMPROP] = HW::GEOMPROP; - _tokenSubstitutions[HW::T_ALPHA_THRESHOLD] = HW::ALPHA_THRESHOLD; - _tokenSubstitutions[HW::T_NUM_ACTIVE_LIGHT_SOURCES] = HW::NUM_ACTIVE_LIGHT_SOURCES; - _tokenSubstitutions[HW::T_ENV_MATRIX] = HW::ENV_MATRIX; - _tokenSubstitutions[HW::T_ENV_RADIANCE] = HW::ENV_RADIANCE; - _tokenSubstitutions[HW::T_ENV_RADIANCE_SAMPLER2D] = HW::ENV_RADIANCE_SAMPLER2D; - _tokenSubstitutions[HW::T_ENV_RADIANCE_MIPS] = HW::ENV_RADIANCE_MIPS; - _tokenSubstitutions[HW::T_ENV_RADIANCE_SAMPLES] = HW::ENV_RADIANCE_SAMPLES; - _tokenSubstitutions[HW::T_ENV_IRRADIANCE] = HW::ENV_IRRADIANCE; - _tokenSubstitutions[HW::T_ENV_IRRADIANCE_SAMPLER2D] = HW::ENV_IRRADIANCE_SAMPLER2D; - _tokenSubstitutions[HW::T_ENV_LIGHT_INTENSITY] = HW::ENV_LIGHT_INTENSITY; - _tokenSubstitutions[HW::T_REFRACTION_TWO_SIDED] = HW::REFRACTION_TWO_SIDED; - _tokenSubstitutions[HW::T_ALBEDO_TABLE] = HW::ALBEDO_TABLE; - _tokenSubstitutions[HW::T_ALBEDO_TABLE_SIZE] = HW::ALBEDO_TABLE_SIZE; - _tokenSubstitutions[HW::T_SHADOW_MAP] = HW::SHADOW_MAP; - _tokenSubstitutions[HW::T_SHADOW_MATRIX] = HW::SHADOW_MATRIX; - _tokenSubstitutions[HW::T_AMB_OCC_MAP] = HW::AMB_OCC_MAP; - _tokenSubstitutions[HW::T_AMB_OCC_GAIN] = HW::AMB_OCC_GAIN; - _tokenSubstitutions[HW::T_VERTEX_DATA_INSTANCE] = HW::VERTEX_DATA_INSTANCE; - _tokenSubstitutions[HW::T_LIGHT_DATA_INSTANCE] = HW::LIGHT_DATA_INSTANCE; - _tokenSubstitutions[HW::T_ENV_PREFILTER_MIP] = HW::ENV_PREFILTER_MIP; - _tokenSubstitutions[HW::T_TEX_SAMPLER_SAMPLER2D] = HW::TEX_SAMPLER_SAMPLER2D; - _tokenSubstitutions[HW::T_TEX_SAMPLER_SIGNATURE] = HW::TEX_SAMPLER_SIGNATURE; - _tokenSubstitutions[HW::T_CLOSURE_DATA_CONSTRUCTOR] = HW::CLOSURE_DATA_CONSTRUCTOR; + _tokenSubstitutions[HW::T_VIEW_MATRIX] = HW::VIEW_MATRIX; + _tokenSubstitutions[HW::T_VIEW_INVERSE_MATRIX] = HW::VIEW_INVERSE_MATRIX; + _tokenSubstitutions[HW::T_VIEW_TRANSPOSE_MATRIX] = HW::VIEW_TRANSPOSE_MATRIX; + _tokenSubstitutions[HW::T_VIEW_INVERSE_TRANSPOSE_MATRIX] = HW::VIEW_INVERSE_TRANSPOSE_MATRIX; + _tokenSubstitutions[HW::T_PROJ_MATRIX] = HW::PROJ_MATRIX; + _tokenSubstitutions[HW::T_PROJ_INVERSE_MATRIX] = HW::PROJ_INVERSE_MATRIX; + _tokenSubstitutions[HW::T_PROJ_TRANSPOSE_MATRIX] = HW::PROJ_TRANSPOSE_MATRIX; + _tokenSubstitutions[HW::T_PROJ_INVERSE_TRANSPOSE_MATRIX] = HW::PROJ_INVERSE_TRANSPOSE_MATRIX; + _tokenSubstitutions[HW::T_WORLD_VIEW_MATRIX] = HW::WORLD_VIEW_MATRIX; + _tokenSubstitutions[HW::T_VIEW_PROJECTION_MATRIX] = HW::VIEW_PROJECTION_MATRIX; + _tokenSubstitutions[HW::T_WORLD_VIEW_PROJECTION_MATRIX] = HW::WORLD_VIEW_PROJECTION_MATRIX; + _tokenSubstitutions[HW::T_VIEW_POSITION] = HW::VIEW_POSITION; + _tokenSubstitutions[HW::T_VIEW_DIRECTION] = HW::VIEW_DIRECTION; + _tokenSubstitutions[HW::T_FRAME] = HW::FRAME; + _tokenSubstitutions[HW::T_TIME] = HW::TIME; + _tokenSubstitutions[HW::T_GEOMPROP] = HW::GEOMPROP; + _tokenSubstitutions[HW::T_ALPHA_THRESHOLD] = HW::ALPHA_THRESHOLD; + _tokenSubstitutions[HW::T_NUM_ACTIVE_LIGHT_SOURCES] = HW::NUM_ACTIVE_LIGHT_SOURCES; + _tokenSubstitutions[HW::T_ENV_MATRIX] = HW::ENV_MATRIX; + _tokenSubstitutions[HW::T_ENV_RADIANCE] = HW::ENV_RADIANCE; + _tokenSubstitutions[HW::T_ENV_RADIANCE_SAMPLER2D] = HW::ENV_RADIANCE_SAMPLER2D; + _tokenSubstitutions[HW::T_ENV_RADIANCE_MIPS] = HW::ENV_RADIANCE_MIPS; + _tokenSubstitutions[HW::T_ENV_RADIANCE_SAMPLES] = HW::ENV_RADIANCE_SAMPLES; + _tokenSubstitutions[HW::T_ENV_IRRADIANCE] = HW::ENV_IRRADIANCE; + _tokenSubstitutions[HW::T_ENV_IRRADIANCE_SAMPLER2D] = HW::ENV_IRRADIANCE_SAMPLER2D; + _tokenSubstitutions[HW::T_ENV_LIGHT_INTENSITY] = HW::ENV_LIGHT_INTENSITY; + _tokenSubstitutions[HW::T_REFRACTION_TWO_SIDED] = HW::REFRACTION_TWO_SIDED; + _tokenSubstitutions[HW::T_ALBEDO_TABLE] = HW::ALBEDO_TABLE; + _tokenSubstitutions[HW::T_ALBEDO_TABLE_SIZE] = HW::ALBEDO_TABLE_SIZE; + _tokenSubstitutions[HW::T_SHADOW_MAP] = HW::SHADOW_MAP; + _tokenSubstitutions[HW::T_SHADOW_MATRIX] = HW::SHADOW_MATRIX; + _tokenSubstitutions[HW::T_AMB_OCC_MAP] = HW::AMB_OCC_MAP; + _tokenSubstitutions[HW::T_AMB_OCC_GAIN] = HW::AMB_OCC_GAIN; + _tokenSubstitutions[HW::T_VERTEX_DATA_INSTANCE] = HW::VERTEX_DATA_INSTANCE; + _tokenSubstitutions[HW::T_LIGHT_DATA_INSTANCE] = HW::LIGHT_DATA_INSTANCE; + _tokenSubstitutions[HW::T_ENV_PREFILTER_MIP] = HW::ENV_PREFILTER_MIP; + _tokenSubstitutions[HW::T_TEX_SAMPLER_SAMPLER2D] = HW::TEX_SAMPLER_SAMPLER2D; + _tokenSubstitutions[HW::T_TEX_SAMPLER_SIGNATURE] = HW::TEX_SAMPLER_SIGNATURE; + _tokenSubstitutions[HW::T_CLOSURE_DATA_CONSTRUCTOR] = HW::CLOSURE_DATA_CONSTRUCTOR; } ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element, GenContext& context) const { // Create the root shader graph ShaderGraphPtr graph = ShaderGraph::create(nullptr, name, element, context); - ShaderPtr shader = std::make_shared(name, graph); + ShaderPtr shader = std::make_shared(name, graph); // Check if there are inputs with default geomprops assigned. In order to bind the // corresponding data to these inputs we insert geomprop nodes in the graph. @@ -100,7 +102,7 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element { if (!socket->getGeomProp().empty()) { - ConstDocumentPtr doc = element->getDocument(); + ConstDocumentPtr doc = element->getDocument(); GeomPropDefPtr geomprop = doc->getGeomPropDef(socket->getGeomProp()); if (geomprop) { @@ -148,13 +150,13 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element vsPrivateUniforms.add(Type::MATRIX44, HW::T_VIEW_PROJECTION_MATRIX); // Create pixel stage. - ShaderStagePtr ps = createStage(Stage::PIXEL, *shader); + ShaderStagePtr ps = createStage(Stage::PIXEL, *shader); VariableBlockPtr psOutputs = ps->createOutputBlock(HW::PIXEL_OUTPUTS, "o_ps"); // Create required Uniform blocks and any additional blocks if needed. VariableBlockPtr psPrivateUniforms = ps->createUniformBlock(HW::PRIVATE_UNIFORMS, "u_prv"); - VariableBlockPtr psPublicUniforms = ps->createUniformBlock(HW::PUBLIC_UNIFORMS, "u_pub"); - VariableBlockPtr lightData = ps->createUniformBlock(HW::LIGHT_DATA, HW::T_LIGHT_DATA_INSTANCE); + VariableBlockPtr psPublicUniforms = ps->createUniformBlock(HW::PUBLIC_UNIFORMS, "u_pub"); + VariableBlockPtr lightData = ps->createUniformBlock(HW::LIGHT_DATA, HW::T_LIGHT_DATA_INSTANCE); lightData->add(Type::INTEGER, getLightDataTypevarString()); // Add a block for data from vertex to pixel shader. @@ -229,7 +231,7 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element // so copy name and variable from the graph output but set type to color4. // TODO: Improve this to support multiple outputs and other data types. ShaderGraphOutputSocket* outputSocket = graph->getOutputSocket(); - ShaderPort* output = psOutputs->add(Type::COLOR4, outputSocket->getName()); + ShaderPort* output = psOutputs->add(Type::COLOR4, outputSocket->getName()); output->setVariable(outputSocket->getVariable()); output->setPath(outputSocket->getPath()); @@ -261,7 +263,7 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element { for (const auto& it : lightShaders->get()) { - ShaderNode* node = it.second.get(); + ShaderNode* node = it.second.get(); ShaderGraph* lightGraph = node->getImplementation().getGraph(); if (lightGraph) { @@ -313,7 +315,7 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element bool HwShaderGenerator::requiresLighting(const ShaderGraph& graph) const { - const bool isBsdf = graph.hasClassification(ShaderNode::Classification::BSDF); + const bool isBsdf = graph.hasClassification(ShaderNode::Classification::BSDF); const bool isLitSurfaceShader = graph.hasClassification(ShaderNode::Classification::SHADER) && graph.hasClassification(ShaderNode::Classification::SURFACE) && !graph.hasClassification(ShaderNode::Classification::UNLIT); diff --git a/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp b/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp index 59e57973ce..41e61a6341 100644 --- a/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwBitangentNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -21,8 +22,8 @@ void HwBitangentNode::createVariables(const ShaderNode& node, GenContext& contex { const GenOptions& options = context.getOptions(); - ShaderStage& vs = shader.getStage(Stage::VERTEX); - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& vs = shader.getStage(Stage::VERTEX); + ShaderStage& ps = shader.getStage(Stage::PIXEL); if (options.hwImplicitBitangents) { @@ -35,7 +36,7 @@ void HwBitangentNode::createVariables(const ShaderNode& node, GenContext& contex } const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; if (space == WORLD_SPACE) { addStageConnector(HW::VERTEX_DATA, Type::VECTOR3, HW::T_BITANGENT_WORLD, vs, ps); @@ -57,15 +58,15 @@ void HwBitangentNode::createVariables(const ShaderNode& node, GenContext& contex void HwBitangentNode::emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const GenOptions& options = context.getOptions(); + const GenOptions& options = context.getOptions(); - const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const ShaderInput* spaceInput = node.getInput(SPACE); + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); if (space == WORLD_SPACE) { ShaderPort* bitangent = vertexData[HW::T_BITANGENT_WORLD]; @@ -118,7 +119,7 @@ void HwBitangentNode::emitFunctionCall(const ShaderNode& node, GenContext& conte DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); if (space == WORLD_SPACE) diff --git a/source/MaterialXGenHw/Nodes/HwFrameNode.cpp b/source/MaterialXGenHw/Nodes/HwFrameNode.cpp index 13de87f408..771f01992b 100644 --- a/source/MaterialXGenHw/Nodes/HwFrameNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwFrameNode.cpp @@ -6,6 +6,7 @@ #include "HwFrameNode.h" #include + #include #include diff --git a/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp b/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp index 0393f067d2..4b51a36b9d 100644 --- a/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwGeomColorNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -20,10 +21,10 @@ ShaderNodeImplPtr HwGeomColorNode::create() void HwGeomColorNode::createVariables(const ShaderNode& node, GenContext&, Shader& shader) const { const ShaderInput* indexInput = node.getInput(INDEX); - const string index = indexInput ? indexInput->getValue()->getValueString() : "0"; + const string index = indexInput ? indexInput->getValue()->getValueString() : "0"; - ShaderStage& vs = shader.getStage(Stage::VERTEX); - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& vs = shader.getStage(Stage::VERTEX); + ShaderStage& ps = shader.getStage(Stage::PIXEL); addStageInput(HW::VERTEX_INPUTS, Type::COLOR4, HW::T_IN_COLOR + "_" + index, vs); addStageConnector(HW::VERTEX_DATA, Type::COLOR4, HW::T_COLOR + "_" + index, vs, ps); } @@ -32,16 +33,16 @@ void HwGeomColorNode::emitFunctionCall(const ShaderNode& node, GenContext& conte { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderOutput* output = node.getOutput(); - const ShaderInput* indexInput = node.getInput(INDEX); - string index = indexInput ? indexInput->getValue()->getValueString() : "0"; - string variable = HW::T_COLOR + "_" + index; + const ShaderOutput* output = node.getOutput(); + const ShaderInput* indexInput = node.getInput(INDEX); + string index = indexInput ? indexInput->getValue()->getValueString() : "0"; + string variable = HW::T_COLOR + "_" + index; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* color = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* color = vertexData[variable]; if (!color->isEmitted()) { color->setEmitted(); @@ -61,8 +62,8 @@ void HwGeomColorNode::emitFunctionCall(const ShaderNode& node, GenContext& conte suffix = ".rgb"; } VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* color = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* color = vertexData[variable]; shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); shadergen.emitString(" = " + prefix + color->getVariable() + suffix, stage); diff --git a/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp b/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp index fc043ca6a6..dc5f4dcbbe 100644 --- a/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwGeomPropValueNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -24,11 +25,11 @@ void HwGeomPropValueNode::createVariables(const ShaderNode& node, GenContext&, S { throw ExceptionShaderGenError("No 'geomprop' parameter found on geompropvalue node '" + node.getName() + "'. Don't know what property to bind"); } - const string geomProp = geomPropInput->getValue()->getValueString(); + const string geomProp = geomPropInput->getValue()->getValueString(); const ShaderOutput* output = node.getOutput(); - ShaderStage& vs = shader.getStage(Stage::VERTEX); - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& vs = shader.getStage(Stage::VERTEX); + ShaderStage& ps = shader.getStage(Stage::PIXEL); addStageInput(HW::VERTEX_INPUTS, output->getType(), HW::T_IN_GEOMPROP + "_" + geomProp, vs); addStageConnector(HW::VERTEX_DATA, output->getType(), HW::T_IN_GEOMPROP + "_" + geomProp, vs, ps); @@ -38,7 +39,7 @@ void HwGeomPropValueNode::emitFunctionCall(const ShaderNode& node, GenContext& c { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderInput* geomPropInput = node.getInput(GEOMPROP); + const ShaderInput* geomPropInput = node.getInput(GEOMPROP); if (!geomPropInput) { throw ExceptionShaderGenError("No 'geomprop' parameter found on geompropvalue node '" + node.getName() + "'. Don't know what property to bind"); @@ -49,8 +50,8 @@ void HwGeomPropValueNode::emitFunctionCall(const ShaderNode& node, GenContext& c DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* geomprop = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* geomprop = vertexData[variable]; if (!geomprop->isEmitted()) { shadergen.emitLine(prefix + geomprop->getVariable() + " = " + HW::T_IN_GEOMPROP + "_" + geomname, stage); @@ -61,8 +62,8 @@ void HwGeomPropValueNode::emitFunctionCall(const ShaderNode& node, GenContext& c DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* geomprop = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* geomprop = vertexData[variable]; shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); shadergen.emitString(" = " + prefix + geomprop->getVariable(), stage); @@ -83,8 +84,8 @@ void HwGeomPropValueNodeAsUniform::createVariables(const ShaderNode& node, GenCo throw ExceptionShaderGenError("No 'geomprop' parameter found on geompropvalue node '" + node.getName() + "'. Don't know what property to bind"); } const string geomProp = geomPropInput->getValue()->getValueString(); - ShaderStage& ps = shader.getStage(Stage::PIXEL); - ShaderPort* uniform = addStageUniform(HW::PRIVATE_UNIFORMS, node.getOutput()->getType(), HW::T_GEOMPROP + "_" + geomProp, ps); + ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderPort* uniform = addStageUniform(HW::PRIVATE_UNIFORMS, node.getOutput()->getType(), HW::T_GEOMPROP + "_" + geomProp, ps); uniform->setPath(geomPropInput->getPath()); } diff --git a/source/MaterialXGenHw/Nodes/HwImageNode.cpp b/source/MaterialXGenHw/Nodes/HwImageNode.cpp index ec502e1f1a..78b73e08a0 100644 --- a/source/MaterialXGenHw/Nodes/HwImageNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwImageNode.cpp @@ -10,7 +10,7 @@ MATERIALX_NAMESPACE_BEGIN // Additional implementation arguments for image nodes -const string UV_SCALE = "uv_scale"; +const string UV_SCALE = "uv_scale"; const string UV_OFFSET = "uv_offset"; ShaderNodeImplPtr HwImageNode::create() diff --git a/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp b/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp index a5c7f6fe59..9ab023a04d 100644 --- a/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightCompoundNode.cpp @@ -26,7 +26,7 @@ void HwLightCompoundNode::initialize(const InterfaceElement& element, GenContext // Store light uniforms for all inputs on the interface const NodeGraph& graph = static_cast(element); - NodeDefPtr nodeDef = graph.getNodeDef(); + NodeDefPtr nodeDef = graph.getNodeDef(); for (InputPtr input : nodeDef->getActiveInputs()) { const TypeDesc type = context.getTypeDesc(input->getType()); @@ -42,7 +42,7 @@ void HwLightCompoundNode::createVariables(const ShaderNode&, GenContext& context childNode->getImplementation().createVariables(*childNode, context, shader); } - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& ps = shader.getStage(Stage::PIXEL); VariableBlock& lightData = ps.getUniformBlock(HW::LIGHT_DATA); // Create all light uniforms diff --git a/source/MaterialXGenHw/Nodes/HwLightNode.cpp b/source/MaterialXGenHw/Nodes/HwLightNode.cpp index a241739080..61454f370d 100644 --- a/source/MaterialXGenHw/Nodes/HwLightNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -56,7 +57,7 @@ void HwLightNode::emitFunctionCall(const ShaderNode& node, GenContext& context, shadergen.emitLineBreak(stage); const ShaderInput* edfInput = node.getInput("edf"); - const ShaderNode* edf = edfInput->getConnectedSibling(); + const ShaderNode* edf = edfInput->getConnectedSibling(); if (edf) { @@ -70,7 +71,7 @@ void HwLightNode::emitFunctionCall(const ShaderNode& node, GenContext& context, shadergen.emitLine("result.intensity = " + edf->getOutput()->getVariable() + " / (distance * distance)", stage); const ShaderInput* intensity = node.getInput("intensity"); - const ShaderInput* exposure = node.getInput("exposure"); + const ShaderInput* exposure = node.getInput("exposure"); shadergen.emitLineBegin(stage); shadergen.emitString("result.intensity *= ", stage); diff --git a/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp b/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp index ba9a5abf7a..8603b3e846 100644 --- a/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightSamplerNode.cpp @@ -7,6 +7,7 @@ #include #include + #include MATERIALX_NAMESPACE_BEGIN diff --git a/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp b/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp index 9a4f9044eb..26ec4117bc 100644 --- a/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwLightShaderNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include diff --git a/source/MaterialXGenHw/Nodes/HwNormalNode.cpp b/source/MaterialXGenHw/Nodes/HwNormalNode.cpp index 8d55399ca6..c5216199ad 100644 --- a/source/MaterialXGenHw/Nodes/HwNormalNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwNormalNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -25,7 +26,7 @@ void HwNormalNode::createVariables(const ShaderNode& node, GenContext&, Shader& addStageInput(HW::VERTEX_INPUTS, Type::VECTOR3, HW::T_IN_NORMAL, vs); const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; if (space == WORLD_SPACE) { addStageUniform(HW::PRIVATE_UNIFORMS, Type::MATRIX44, HW::T_WORLD_INVERSE_TRANSPOSE_MATRIX, vs); @@ -41,13 +42,13 @@ void HwNormalNode::emitFunctionCall(const ShaderNode& node, GenContext& context, { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const ShaderInput* spaceInput = node.getInput(SPACE); + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); if (space == WORLD_SPACE) { ShaderPort* normal = vertexData[HW::T_NORMAL_WORLD]; @@ -71,7 +72,7 @@ void HwNormalNode::emitFunctionCall(const ShaderNode& node, GenContext& context, DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); if (space == WORLD_SPACE) diff --git a/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp b/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp index 133b3bd883..8b1965bc07 100644 --- a/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwNumLightsNode.cpp @@ -6,6 +6,7 @@ #include "HwNumLightsNode.h" #include + #include #include @@ -31,7 +32,7 @@ ShaderNodeImplPtr HwNumLightsNode::create() void HwNumLightsNode::createVariables(const ShaderNode&, GenContext&, Shader& shader) const { // Create uniform for number of active light sources - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& ps = shader.getStage(Stage::PIXEL); ShaderPort* numActiveLights = addStageUniform(HW::PRIVATE_UNIFORMS, Type::INTEGER, HW::T_NUM_ACTIVE_LIGHT_SOURCES, ps); numActiveLights->setValue(Value::createValue(0)); } diff --git a/source/MaterialXGenHw/Nodes/HwPositionNode.cpp b/source/MaterialXGenHw/Nodes/HwPositionNode.cpp index 09b76f951e..1de3abc605 100644 --- a/source/MaterialXGenHw/Nodes/HwPositionNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwPositionNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -25,7 +26,7 @@ void HwPositionNode::createVariables(const ShaderNode& node, GenContext&, Shader addStageInput(HW::VERTEX_INPUTS, Type::VECTOR3, HW::T_IN_POSITION, vs); const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; if (space == WORLD_SPACE) { addStageConnector(HW::VERTEX_DATA, Type::VECTOR3, HW::T_POSITION_WORLD, vs, ps); @@ -40,13 +41,13 @@ void HwPositionNode::emitFunctionCall(const ShaderNode& node, GenContext& contex { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const ShaderInput* spaceInput = node.getInput(SPACE); + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); if (space == WORLD_SPACE) { ShaderPort* position = vertexData[HW::T_POSITION_WORLD]; @@ -70,7 +71,7 @@ void HwPositionNode::emitFunctionCall(const ShaderNode& node, GenContext& contex DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); if (space == WORLD_SPACE) diff --git a/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp b/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp index 1cfe766cd3..5646c5aa7c 100644 --- a/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -52,8 +53,8 @@ void HwSurfaceNode::emitFunctionCall(const ShaderNode& node, GenContext& context DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* position = vertexData[HW::T_POSITION_WORLD]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* position = vertexData[HW::T_POSITION_WORLD]; if (!position->isEmitted()) { position->setEmitted(); @@ -79,7 +80,7 @@ void HwSurfaceNode::emitFunctionCall(const ShaderNode& node, GenContext& context DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); // Declare the output variable const ShaderOutput* output = node.getOutput(); @@ -96,7 +97,7 @@ void HwSurfaceNode::emitFunctionCall(const ShaderNode& node, GenContext& context shadergen.emitLine("float occlusion = 1.0", stage); shadergen.emitLineBreak(stage); - const string outColor = output->getVariable() + ".color"; + const string outColor = output->getVariable() + ".color"; const string outTransparency = output->getVariable() + ".transparency"; const ShaderInput* bsdfInput = node.getInput("bsdf"); @@ -235,11 +236,11 @@ void HwSurfaceNode::emitLightLoop(const ShaderNode& node, GenContext& context, S if (context.getOptions().hwMaxActiveLightSources > 0) { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); + const string prefix = shadergen.getVertexDataPrefix(vertexData); - const ShaderInput* bsdfInput = node.getInput("bsdf"); - const ShaderNode* bsdf = bsdfInput->getConnectedSibling(); + const ShaderInput* bsdfInput = node.getInput("bsdf"); + const ShaderNode* bsdf = bsdfInput->getConnectedSibling(); shadergen.emitComment("Light loop", stage); shadergen.emitLine("int numLights = numActiveLightSources()", stage); diff --git a/source/MaterialXGenHw/Nodes/HwTangentNode.cpp b/source/MaterialXGenHw/Nodes/HwTangentNode.cpp index 8930f4a2cc..f16bd212d8 100644 --- a/source/MaterialXGenHw/Nodes/HwTangentNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTangentNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -25,7 +26,7 @@ void HwTangentNode::createVariables(const ShaderNode& node, GenContext&, Shader& addStageInput(HW::VERTEX_INPUTS, Type::VECTOR3, HW::T_IN_TANGENT, vs); const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; if (space == WORLD_SPACE) { addStageUniform(HW::PRIVATE_UNIFORMS, Type::MATRIX44, HW::T_WORLD_MATRIX, vs); @@ -41,13 +42,13 @@ void HwTangentNode::emitFunctionCall(const ShaderNode& node, GenContext& context { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const ShaderInput* spaceInput = node.getInput(SPACE); + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); if (space == WORLD_SPACE) { ShaderPort* tangent = vertexData[HW::T_TANGENT_WORLD]; @@ -71,7 +72,7 @@ void HwTangentNode::emitFunctionCall(const ShaderNode& node, GenContext& context DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); if (space == WORLD_SPACE) diff --git a/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp b/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp index 6544835ac0..5d83ec6baf 100644 --- a/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTexCoordNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -22,10 +23,10 @@ ShaderNodeImplPtr HwTexCoordNode::create() void HwTexCoordNode::createVariables(const ShaderNode& node, GenContext&, Shader& shader) const { const ShaderOutput* output = node.getOutput(); - const string index = getIndex(node); + const string index = getIndex(node); - ShaderStage& vs = shader.getStage(Stage::VERTEX); - ShaderStage& ps = shader.getStage(Stage::PIXEL); + ShaderStage& vs = shader.getStage(Stage::VERTEX); + ShaderStage& ps = shader.getStage(Stage::PIXEL); addStageInput(HW::VERTEX_INPUTS, output->getType(), HW::T_IN_TEXCOORD + "_" + index, vs, true); addStageConnector(HW::VERTEX_DATA, output->getType(), HW::T_TEXCOORD + "_" + index, vs, ps, true); @@ -35,15 +36,15 @@ void HwTexCoordNode::emitFunctionCall(const ShaderNode& node, GenContext& contex { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const string index = getIndex(node); - const string variable = HW::T_TEXCOORD + "_" + index; - const ShaderOutput* output = node.getOutput(); + const string index = getIndex(node); + const string variable = HW::T_TEXCOORD + "_" + index; + const ShaderOutput* output = node.getOutput(); DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* texcoord = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* texcoord = vertexData[variable]; if (!texcoord->isEmitted()) { shadergen.emitLine(prefix + texcoord->getVariable() + " = " + HW::T_IN_TEXCOORD + "_" + index, stage); @@ -54,8 +55,8 @@ void HwTexCoordNode::emitFunctionCall(const ShaderNode& node, GenContext& contex DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* texcoord = vertexData[variable]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* texcoord = vertexData[variable]; shadergen.emitLineBegin(stage); shadergen.emitOutput(output, true, false, context, stage); diff --git a/source/MaterialXGenHw/Nodes/HwTexCoordNode.h b/source/MaterialXGenHw/Nodes/HwTexCoordNode.h index 3c20c40ca8..300826cf6f 100644 --- a/source/MaterialXGenHw/Nodes/HwTexCoordNode.h +++ b/source/MaterialXGenHw/Nodes/HwTexCoordNode.h @@ -7,6 +7,7 @@ #define MATERIALX_HWTEXCOORDNODE_H #include + #include MATERIALX_NAMESPACE_BEGIN diff --git a/source/MaterialXGenHw/Nodes/HwTimeNode.cpp b/source/MaterialXGenHw/Nodes/HwTimeNode.cpp index 3f75fb8df1..cfc988b665 100644 --- a/source/MaterialXGenHw/Nodes/HwTimeNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTimeNode.cpp @@ -6,6 +6,7 @@ #include "HwTimeNode.h" #include + #include #include diff --git a/source/MaterialXGenHw/Nodes/HwTransformNode.cpp b/source/MaterialXGenHw/Nodes/HwTransformNode.cpp index 6ac052bbad..e6199e428f 100644 --- a/source/MaterialXGenHw/Nodes/HwTransformNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwTransformNode.cpp @@ -6,22 +6,23 @@ #include "HwTransformNode.h" #include + #include #include MATERIALX_NAMESPACE_BEGIN const string HwTransformNode::FROM_SPACE = "fromspace"; -const string HwTransformNode::TO_SPACE = "tospace"; -const string HwTransformNode::MODEL = "model"; -const string HwTransformNode::OBJECT = "object"; -const string HwTransformNode::WORLD = "world"; +const string HwTransformNode::TO_SPACE = "tospace"; +const string HwTransformNode::MODEL = "model"; +const string HwTransformNode::OBJECT = "object"; +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); + const string& matrix = getMatrix(fromSpace, toSpace); if (!matrix.empty()) { ShaderStage& ps = shader.getStage(Stage::PIXEL); @@ -35,8 +36,8 @@ void HwTransformNode::emitFunctionCall(const ShaderNode& node, GenContext& conte { const ShaderGenerator& shadergen = context.getShaderGenerator(); - const ShaderOutput* output = node.getOutput(); - const ShaderInput* inInput = node.getInput("in"); + const ShaderOutput* output = node.getOutput(); + const ShaderInput* inInput = node.getInput("in"); if (inInput->getType() != Type::VECTOR3 && inInput->getType() != Type::VECTOR4) { throw ExceptionShaderGenError("Transform node must have 'in' type of vector3 or vector4."); @@ -45,9 +46,9 @@ void HwTransformNode::emitFunctionCall(const ShaderNode& node, GenContext& conte shadergen.emitLineBegin(stage); shadergen.emitOutput(output, true, false, context, stage); - const string toSpace = getToSpace(node); + const string toSpace = getToSpace(node); const string fromSpace = getFromSpace(node); - const string& matrix = getMatrix(fromSpace, toSpace); + const string& matrix = getMatrix(fromSpace, toSpace); if (matrix.empty()) { shadergen.emitString(" = (", stage); @@ -57,7 +58,7 @@ void HwTransformNode::emitFunctionCall(const ShaderNode& node, GenContext& conte shadergen.emitString(" = mx_matrix_mul(" + matrix + ", ", stage); } - const string type = shadergen.getSyntax().getTypeName(Type::VECTOR4); + const string type = shadergen.getSyntax().getTypeName(Type::VECTOR4); const string input = shadergen.getUpstreamResult(inInput, context); shadergen.emitString(type + "(" + input + ", " + getHomogeneousCoordinate() + ")).xyz", stage); shadergen.emitLineEnd(stage); diff --git a/source/MaterialXGenHw/Nodes/HwTransformNode.h b/source/MaterialXGenHw/Nodes/HwTransformNode.h index b0e39ee7de..408d601cb3 100644 --- a/source/MaterialXGenHw/Nodes/HwTransformNode.h +++ b/source/MaterialXGenHw/Nodes/HwTransformNode.h @@ -7,8 +7,8 @@ #define MATERIALX_HWTRANSFORMNODE_H #include - #include + #include MATERIALX_NAMESPACE_BEGIN @@ -24,7 +24,7 @@ class MX_GENHW_API HwTransformNode : public ShaderNodeImpl virtual const string& getMatrix(const string& fromSpace, const string& toSpace) const; virtual const string& getModelToWorldMatrix() const = 0; virtual const string& getWorldToModelMatrix() const = 0; - virtual string getHomogeneousCoordinate() const = 0; + virtual string getHomogeneousCoordinate() const = 0; virtual bool shouldNormalize() const { return false; } virtual string getFromSpace(const ShaderNode&) const; diff --git a/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp b/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp index adbc213146..68e9159242 100644 --- a/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp +++ b/source/MaterialXGenHw/Nodes/HwViewDirectionNode.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -25,7 +26,7 @@ void HwViewDirectionNode::createVariables(const ShaderNode& node, GenContext&, S addStageInput(HW::VERTEX_INPUTS, Type::VECTOR3, HW::T_IN_POSITION, vs); const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; addStageUniform(HW::PRIVATE_UNIFORMS, Type::VECTOR3, HW::T_VIEW_POSITION, ps); addStageConnector(HW::VERTEX_DATA, Type::VECTOR3, HW::T_POSITION_WORLD, vs, ps); @@ -39,14 +40,14 @@ void HwViewDirectionNode::emitFunctionCall(const ShaderNode& node, GenContext& c { const HwShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - const ShaderInput* spaceInput = node.getInput(SPACE); - const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; + const ShaderInput* spaceInput = node.getInput(SPACE); + const int space = spaceInput ? spaceInput->getValue()->asA() : OBJECT_SPACE; DEFINE_SHADER_STAGE(stage, Stage::VERTEX) { VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); - ShaderPort* position = vertexData[HW::T_POSITION_WORLD]; + const string prefix = shadergen.getVertexDataPrefix(vertexData); + ShaderPort* position = vertexData[HW::T_POSITION_WORLD]; if (!position->isEmitted()) { position->setEmitted(); @@ -57,7 +58,7 @@ void HwViewDirectionNode::emitFunctionCall(const ShaderNode& node, GenContext& c DEFINE_SHADER_STAGE(stage, Stage::PIXEL) { VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA); - const string prefix = shadergen.getVertexDataPrefix(vertexData); + const string prefix = shadergen.getVertexDataPrefix(vertexData); shadergen.emitLineBegin(stage); shadergen.emitOutput(node.getOutput(), true, false, context, stage); ShaderPort* position = vertexData[HW::T_POSITION_WORLD];