diff --git a/resources/Materials/TestSuite/stdlib/geometric/geompropvalue.mtlx b/resources/Materials/TestSuite/stdlib/geometric/geompropvalue.mtlx
index 28cc80328a..47038e43c8 100644
--- a/resources/Materials/TestSuite/stdlib/geometric/geompropvalue.mtlx
+++ b/resources/Materials/TestSuite/stdlib/geometric/geompropvalue.mtlx
@@ -4,11 +4,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
index 7816a44dba..e59e9334fc 100644
--- a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
+++ b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
@@ -220,8 +220,8 @@ GlslShaderGenerator::GlslShaderGenerator() :
registerImplementation("IM_geomcolor_color4_" + GlslShaderGenerator::LANGUAGE, GeomColorNodeGlsl::create);
//
registerImplementation("IM_geompropvalue_integer_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
- registerImplementation("IM_geompropvalue_boolean_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
- registerImplementation("IM_geompropvalue_string_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
+ registerImplementation("IM_geompropvalue_boolean_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl_asUniform::create);
+ registerImplementation("IM_geompropvalue_string_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl_asUniform::create);
registerImplementation("IM_geompropvalue_float_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
registerImplementation("IM_geompropvalue_color2_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
registerImplementation("IM_geompropvalue_color3_" + GlslShaderGenerator::LANGUAGE, GeomPropValueNodeGlsl::create);
@@ -753,6 +753,11 @@ void GlslShaderGenerator::emitVariableDeclaration(const ShaderPort* variable, co
else
{
string str = qualifier.empty() ? EMPTY_STRING : qualifier + " ";
+ // Varying parameters of type int must be flat qualified on output from vertex stage and
+ // input to pixel stage. The only way to get these is with geompropvalue_integer nodes.
+ if (qualifier.empty() && variable->getType() == Type::INTEGER && !assignValue && variable->getName().rfind(HW::T_IN_GEOMPROP, 0) == 0) {
+ str += GlslSyntax::FLAT_QUALIFIER + " ";
+ }
str += _syntax->getTypeName(variable->getType()) + " " + variable->getVariable();
// If an array we need an array qualifier (suffix) for the variable name
diff --git a/source/MaterialXGenGlsl/GlslSyntax.cpp b/source/MaterialXGenGlsl/GlslSyntax.cpp
index 05cbc39d9c..f054629d34 100644
--- a/source/MaterialXGenGlsl/GlslSyntax.cpp
+++ b/source/MaterialXGenGlsl/GlslSyntax.cpp
@@ -102,6 +102,7 @@ const string GlslSyntax::INPUT_QUALIFIER = "in";
const string GlslSyntax::OUTPUT_QUALIFIER = "out";
const string GlslSyntax::UNIFORM_QUALIFIER = "uniform";
const string GlslSyntax::CONSTANT_QUALIFIER = "const";
+const string GlslSyntax::FLAT_QUALIFIER = "flat";
const string GlslSyntax::SOURCE_FILE_EXTENSION = ".glsl";
const StringVec GlslSyntax::VEC2_MEMBERS = { ".x", ".y" };
const StringVec GlslSyntax::VEC3_MEMBERS = { ".x", ".y", ".z" };
diff --git a/source/MaterialXGenGlsl/GlslSyntax.h b/source/MaterialXGenGlsl/GlslSyntax.h
index 2c3e158aab..1aea7593f0 100644
--- a/source/MaterialXGenGlsl/GlslSyntax.h
+++ b/source/MaterialXGenGlsl/GlslSyntax.h
@@ -38,6 +38,7 @@ class GlslSyntax : public Syntax
static const string OUTPUT_QUALIFIER;
static const string UNIFORM_QUALIFIER;
static const string CONSTANT_QUALIFIER;
+ static const string FLAT_QUALIFIER;
static const string SOURCE_FILE_EXTENSION;
static const StringVec VEC2_MEMBERS;
diff --git a/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.cpp b/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.cpp
index 48ec4fe0c6..e2761a60ed 100644
--- a/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.cpp
+++ b/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.cpp
@@ -20,7 +20,63 @@ void GeomPropValueNodeGlsl::createVariables(const ShaderNode& node, GenContext&,
const ShaderInput* geomPropInput = node.getInput(GEOMPROP);
if (!geomPropInput || !geomPropInput->getValue())
{
- throw ExceptionShaderGenError("No 'geomprop' parameter found on geompropvalue node '" + node.getName() + "', don't know what property to bind");
+ 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 ShaderOutput* output = node.getOutput();
+
+ 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);
+}
+
+void GeomPropValueNodeGlsl::emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
+{
+ const ShaderGenerator& shadergen = context.getShaderGenerator();
+
+ 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");
+ }
+ const string geomname = geomPropInput->getValue()->getValueString();
+ const string variable = HW::T_IN_GEOMPROP + "_" + geomname;
+
+ BEGIN_SHADER_STAGE(stage, Stage::VERTEX)
+ VariableBlock& vertexData = stage.getOutputBlock(HW::VERTEX_DATA);
+ const string prefix = vertexData.getInstance() + ".";
+ ShaderPort* geomprop = vertexData[variable];
+ if (!geomprop->isEmitted())
+ {
+ shadergen.emitLine(prefix + geomprop->getVariable() + " = " + HW::T_IN_GEOMPROP + "_" + geomname, stage);
+ geomprop->setEmitted();
+ }
+ END_SHADER_STAGE(shader, Stage::VERTEX)
+
+ BEGIN_SHADER_STAGE(stage, Stage::PIXEL)
+ VariableBlock& vertexData = stage.getInputBlock(HW::VERTEX_DATA);
+ const string prefix = vertexData.getInstance() + ".";
+ ShaderPort* geomprop = vertexData[variable];
+ shadergen.emitLineBegin(stage);
+ shadergen.emitOutput(node.getOutput(), true, false, context, stage);
+ shadergen.emitString(" = " + prefix + geomprop->getVariable(), stage);
+ shadergen.emitLineEnd(stage);
+ END_SHADER_STAGE(shader, Stage::PIXEL)
+}
+
+ShaderNodeImplPtr GeomPropValueNodeGlsl_asUniform::create()
+{
+ return std::make_shared();
+}
+
+void GeomPropValueNodeGlsl_asUniform::createVariables(const ShaderNode& node, GenContext&, Shader& shader) const
+{
+ const ShaderInput* geomPropInput = node.getInput(GEOMPROP);
+ if (!geomPropInput || !geomPropInput->getValue())
+ {
+ 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);
@@ -28,14 +84,14 @@ void GeomPropValueNodeGlsl::createVariables(const ShaderNode& node, GenContext&,
uniform->setPath(geomPropInput->getPath());
}
-void GeomPropValueNodeGlsl::emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
+void GeomPropValueNodeGlsl_asUniform::emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
{
BEGIN_SHADER_STAGE(stage, Stage::PIXEL)
const ShaderGenerator& shadergen = context.getShaderGenerator();
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");
+ throw ExceptionShaderGenError("No 'geomprop' parameter found on geompropvalue node '" + node.getName() + "'. Don't know what property to bind");
}
const string attrName = geomPropInput->getValue()->getValueString();
shadergen.emitLineBegin(stage);
diff --git a/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.h
index 838ffa8461..c1acea3bce 100644
--- a/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/GeomPropValueNodeGlsl.h
@@ -20,6 +20,19 @@ class GeomPropValueNodeGlsl : public GlslImplementation
void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
+
+ bool isEditable(const ShaderInput& /*input*/) const override { return false; }
+};
+
+/// GeomPropValue node non-implementation for GLSL
+class GeomPropValueNodeGlsl_asUniform : public GlslImplementation
+{
+public:
+ static ShaderNodeImplPtr create();
+
+ void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
+
+ void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
};
} // namespace MaterialX
diff --git a/source/MaterialXGenOgsXml/OgsFragment.h b/source/MaterialXGenOgsXml/OgsFragment.h
index 939c4b0cd4..cd7f833805 100644
--- a/source/MaterialXGenOgsXml/OgsFragment.h
+++ b/source/MaterialXGenOgsXml/OgsFragment.h
@@ -48,6 +48,12 @@ class OgsFragment
return _element ? _element->getDocument() : mx::DocumentPtr();
}
+ /// Get the GLSL shader generated for this fragment
+ mx::ShaderPtr getShader() const
+ {
+ return _glslShader;
+ }
+
/// Return the source of the OGS fragment as a string.
const std::string& getFragmentSource() const;
diff --git a/source/MaterialXGenOgsXml/OgsXmlGenerator.cpp b/source/MaterialXGenOgsXml/OgsXmlGenerator.cpp
index d51150d324..89137e6b2a 100644
--- a/source/MaterialXGenOgsXml/OgsXmlGenerator.cpp
+++ b/source/MaterialXGenOgsXml/OgsXmlGenerator.cpp
@@ -56,8 +56,6 @@ namespace
{ "Tm", "Tm" },
{ "Bw", "Bw" },
{ "Bm", "Bm" },
- { "texcoord_0", "mayaUvCoordSemantic" },
- { "color_0", "colorset" },
{ "u_worldMatrix", "World" },
{ "u_worldInverseMatrix", "WorldInverse" },
@@ -85,6 +83,13 @@ namespace
{ "u_time", "Time" }
};
+ static const vector > OGS_SEMANTICS_PREFIX_MAP =
+ {
+ { "texcoord_", "mayaUvCoordSemantic" },
+ { "color_", "colorset" },
+ { "i_geomprop_", "mayaUvCoordSemantic" }
+ };
+
namespace OgsParameterFlags
{
static const std::string
@@ -143,6 +148,12 @@ namespace
{
prop.append_attribute(SEMANTIC) = semantic->second;
}
+ for (auto const& ogsSemantic: OGS_SEMANTICS_PREFIX_MAP) {
+ // STL startswith:
+ if (name.rfind(ogsSemantic.first, 0) == 0) {
+ prop.append_attribute(SEMANTIC) = ogsSemantic.second;
+ }
+ }
if (!parameterFlags.empty())
{
prop.append_attribute(FLAGS) = parameterFlags.c_str();
diff --git a/source/MaterialXGenShader/HwShaderGenerator.cpp b/source/MaterialXGenShader/HwShaderGenerator.cpp
index aa4590d8fd..3b97ba0de4 100644
--- a/source/MaterialXGenShader/HwShaderGenerator.cpp
+++ b/source/MaterialXGenShader/HwShaderGenerator.cpp
@@ -24,6 +24,7 @@ namespace HW
const string T_IN_NORMAL = "$inNormal";
const string T_IN_TANGENT = "$inTangent";
const string T_IN_TEXCOORD = "$inTexcoord";
+ const string T_IN_GEOMPROP = "$inGeomprop";
const string T_IN_COLOR = "$inColor";
const string T_POSITION_WORLD = "$positionWorld";
const string T_NORMAL_WORLD = "$normalWorld";
@@ -75,6 +76,7 @@ namespace HW
const string IN_NORMAL = "i_normal";
const string IN_TANGENT = "i_tangent";
const string IN_TEXCOORD = "i_texcoord";
+ const string IN_GEOMPROP = "i_geomprop";
const string IN_COLOR = "i_color";
const string POSITION_WORLD = "positionWorld";
const string NORMAL_WORLD = "normalWorld";
@@ -166,6 +168,7 @@ HwShaderGenerator::HwShaderGenerator(SyntaxPtr syntax) :
_tokenSubstitutions[HW::T_IN_NORMAL] = HW::IN_NORMAL;
_tokenSubstitutions[HW::T_IN_TANGENT] = HW::IN_TANGENT;
_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;
diff --git a/source/MaterialXGenShader/HwShaderGenerator.h b/source/MaterialXGenShader/HwShaderGenerator.h
index 0cf26e8dd4..1fac6f83eb 100644
--- a/source/MaterialXGenShader/HwShaderGenerator.h
+++ b/source/MaterialXGenShader/HwShaderGenerator.h
@@ -87,6 +87,7 @@ namespace HW
extern const string T_IN_NORMAL;
extern const string T_IN_TANGENT;
extern const string T_IN_TEXCOORD;
+ extern const string T_IN_GEOMPROP;
extern const string T_IN_COLOR;
extern const string T_POSITION_WORLD;
extern const string T_NORMAL_WORLD;
@@ -140,6 +141,7 @@ namespace HW
extern const string IN_NORMAL;
extern const string IN_TANGENT;
extern const string IN_TEXCOORD;
+ extern const string IN_GEOMPROP;
extern const string IN_COLOR;
extern const string POSITION_WORLD;
extern const string NORMAL_WORLD;
diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp
index 96129f8c49..fc68d9b76f 100644
--- a/source/MaterialXGenShader/ShaderGraph.cpp
+++ b/source/MaterialXGenShader/ShaderGraph.cpp
@@ -1508,7 +1508,7 @@ void ShaderGraph::calculateScopes()
{
newScopeInfo.adjustAtConditionalInput(node, int(inputIndex), 0x12);
}
- else if (isSwitch)
+ else if (isSwitch && inputIndex != node->numInputs() - 1)
{
const uint32_t fullMask = (1 << node->numInputs()) - 1;
newScopeInfo.adjustAtConditionalInput(node, int(inputIndex), fullMask);
diff --git a/source/MaterialXRenderGlsl/GlslProgram.cpp b/source/MaterialXRenderGlsl/GlslProgram.cpp
index 665305a6b8..a21a025f6e 100644
--- a/source/MaterialXRenderGlsl/GlslProgram.cpp
+++ b/source/MaterialXRenderGlsl/GlslProgram.cpp
@@ -368,7 +368,11 @@ void GlslProgram::bindAttribute(const GlslProgram::InputMap& inputs, MeshPtr mes
glEnableVertexAttribArray(location);
_enabledStreamLocations.insert(location);
- glVertexAttribPointer(location, stride, GL_FLOAT, GL_FALSE, 0, nullptr);
+ if (input.second->gltype != GL_INT) {
+ glVertexAttribPointer(location, stride, GL_FLOAT, GL_FALSE, 0, nullptr);
+ } else {
+ glVertexAttribIPointer(location, stride, GL_INT, 0, nullptr);
+ }
}
}
@@ -463,7 +467,14 @@ void GlslProgram::bindStreams(MeshPtr mesh)
bindAttribute(foundList, mesh);
}
- // Bind any named geometric property information
+ // Bind any named varying geometric property information
+ findInputs(HW::IN_GEOMPROP + "_", attributeList, foundList, false);
+ if (foundList.size())
+ {
+ bindAttribute(foundList, mesh);
+ }
+
+ // Bind any named uniform geometric property information
const GlslProgram::InputMap& uniformList = getUniformsList();
findInputs(HW::GEOMPROP + "_", uniformList, foundList, false);
for (const auto& input : foundList)
diff --git a/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h b/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h
index 50d396448d..57c28c0c98 100644
--- a/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h
+++ b/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h
@@ -53,9 +53,9 @@ class GlslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester
whiteList =
{
"ambientocclusion", "arrayappend", "backfacing", "screen", "curveadjust", "displacementshader",
- "volumeshader", "IM_constant_", "IM_dot_", "IM_geompropvalue", "IM_light_genglsl",
- "IM_point_light_genglsl", "IM_spot_light_genglsl", "IM_directional_light_genglsl", "IM_angle",
- "surfacematerial", "volumematerial", "ND_surfacematerial", "ND_volumematerial"
+ "volumeshader", "IM_constant_", "IM_dot_", "IM_geompropvalue_boolean", "IM_geompropvalue_string",
+ "IM_light_genglsl", "IM_point_light_genglsl", "IM_spot_light_genglsl", "IM_directional_light_genglsl",
+ "IM_angle", "surfacematerial", "volumematerial", "ND_surfacematerial", "ND_volumematerial"
};
}
};
diff --git a/source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp b/source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp
index a94b76f195..05b9e5bc81 100644
--- a/source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp
+++ b/source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp
@@ -28,6 +28,8 @@
#include
#include
+#include
+
namespace mx = MaterialX;
//
@@ -65,7 +67,6 @@ class GlslShaderRenderTester : public RenderUtil::ShaderRenderTester
bool saveImage(const mx::FilePath& filePath, mx::ConstImagePtr image, bool verticalFlip) const override;
-
bool canBake() const override
{
return true;
@@ -210,12 +211,107 @@ void addAdditionalTestStreams(mx::MeshPtr mesh)
mesh->addStream(colorStream2);
}
+ const std::string GEOM_INT_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_integer");
+ int32_t* geomIntData = nullptr;
+ if (!mesh->getStream(GEOM_INT_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomIntStream = mx::MeshStream::create(GEOM_INT_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 0);
+ geomIntStream->setStride(1);
+ geomIntStream->getData().resize(vertexCount);
+ mesh->addStream(geomIntStream);
+ // Float and int32 have same size.
+ geomIntData = reinterpret_cast(geomIntStream->getData().data());
+ }
+
+ const std::string GEOM_FLOAT_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_float");
+ mx::MeshFloatBuffer* geomFloatData = nullptr;
+ if (!mesh->getStream(GEOM_FLOAT_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomFloatStream = mx::MeshStream::create(GEOM_FLOAT_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomFloatData = &(geomFloatStream->getData());
+ geomFloatStream->setStride(1);
+ geomFloatData->resize(vertexCount);
+ mesh->addStream(geomFloatStream);
+ }
+
+ const std::string GEOM_VECTOR2_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_vector2");
+ mx::MeshFloatBuffer* geomVector2Data = nullptr;
+ if (!mesh->getStream(GEOM_VECTOR2_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomVector2Stream = mx::MeshStream::create(GEOM_VECTOR2_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomVector2Data = &(geomVector2Stream->getData());
+ geomVector2Stream->setStride(2);
+ geomVector2Data->resize(vertexCount * 2);
+ mesh->addStream(geomVector2Stream);
+ }
+
+ const std::string GEOM_VECTOR3_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_vector3");
+ mx::MeshFloatBuffer* geomVector3Data = nullptr;
+ if (!mesh->getStream(GEOM_VECTOR3_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomVector3Stream = mx::MeshStream::create(GEOM_VECTOR3_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomVector3Data = &(geomVector3Stream->getData());
+ geomVector3Stream->setStride(3);
+ geomVector3Data->resize(vertexCount * 3);
+ mesh->addStream(geomVector3Stream);
+ }
+
+ const std::string GEOM_VECTOR4_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_vector4");
+ mx::MeshFloatBuffer* geomVector4Data = nullptr;
+ if (!mesh->getStream(GEOM_VECTOR4_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomVector4Stream = mx::MeshStream::create(GEOM_VECTOR4_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomVector4Data = &(geomVector4Stream->getData());
+ geomVector4Stream->setStride(4);
+ geomVector4Data->resize(vertexCount * 4);
+ mesh->addStream(geomVector4Stream);
+ }
+
+ const std::string GEOM_COLOR2_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_color2");
+ mx::MeshFloatBuffer* geomColor2Data = nullptr;
+ if (!mesh->getStream(GEOM_COLOR2_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomColor2Stream = mx::MeshStream::create(GEOM_COLOR2_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomColor2Data = &(geomColor2Stream->getData());
+ geomColor2Stream->setStride(2);
+ geomColor2Data->resize(vertexCount * 2);
+ mesh->addStream(geomColor2Stream);
+ }
+
+ const std::string GEOM_COLOR3_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_color3");
+ mx::MeshFloatBuffer* geomColor3Data = nullptr;
+ if (!mesh->getStream(GEOM_COLOR3_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomColor3Stream = mx::MeshStream::create(GEOM_COLOR3_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomColor3Data = &(geomColor3Stream->getData());
+ geomColor3Stream->setStride(3);
+ geomColor3Data->resize(vertexCount * 3);
+ mesh->addStream(geomColor3Stream);
+ }
+
+ const std::string GEOM_COLOR4_STREAM_NAME("i_" + mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE + "_geompropvalue_color4");
+ mx::MeshFloatBuffer* geomColor4Data = nullptr;
+ if (!mesh->getStream(GEOM_COLOR4_STREAM_NAME))
+ {
+ mx::MeshStreamPtr geomColor4Stream = mx::MeshStream::create(GEOM_COLOR4_STREAM_NAME, mx::MeshStream::GEOMETRY_PROPERTY_ATTRIBUTE, 1);
+ geomColor4Data = &(geomColor4Stream->getData());
+ geomColor4Stream->setStride(4);
+ geomColor4Data->resize(vertexCount * 4);
+ mesh->addStream(geomColor4Stream);
+ }
+
+ auto sineData = [](float uv, float freq){
+ const float PI = std::acos(-1.0f);
+ float angle = uv * 2 * PI * freq;
+ return std::sin(angle) / 2.0f + 1.0f;
+ };
if (!uv.empty())
{
for (size_t i = 0; i < vertexCount; i++)
{
const size_t i2 = 2 * i;
const size_t i21 = i2 + 1;
+ const size_t i3 = 3 * i;
const size_t i4 = 4 * i;
// Fake second set of texture coordinates
@@ -239,6 +335,51 @@ void addAdditionalTestStreams(mx::MeshPtr mesh)
(*colorData2)[i4 + 2] = uv[i21];
(*colorData2)[i4 + 3] = 1.0f;
}
+ if (geomIntData)
+ {
+ geomIntData[i] = static_cast(uv[i21] * 5);
+ }
+ if (geomFloatData)
+ {
+ (*geomFloatData)[i] = sineData(uv[i21], 12.0f);
+ }
+ if (geomVector2Data)
+ {
+ (*geomVector2Data)[i2] = sineData(uv[i21], 6.0f);
+ (*geomVector2Data)[i21] = 0.0f;
+ }
+ if (geomVector3Data)
+ {
+ (*geomVector3Data)[i3] = 0.0f;
+ (*geomVector3Data)[i3 + 1] = sineData(uv[i21], 8.0f);
+ (*geomVector3Data)[i3 + 2] = 0.0f;
+ }
+ if (geomVector4Data)
+ {
+ (*geomVector4Data)[i4] = 0.0f;
+ (*geomVector4Data)[i4 + 1] = 0.0f;
+ (*geomVector4Data)[i4 + 2] = sineData(uv[i21], 10.0f);
+ (*geomVector4Data)[i4 + 3] = 1.0f;
+ }
+
+ if (geomColor2Data)
+ {
+ (*geomColor2Data)[i2] = sineData(uv[i2], 10.0f);
+ (*geomColor2Data)[i21] = 0.0f;
+ }
+ if (geomColor3Data)
+ {
+ (*geomColor3Data)[i3] = 0.0f;
+ (*geomColor3Data)[i3 + 1] = sineData(uv[i2], 8.0f);
+ (*geomColor3Data)[i3 + 2] = 0.0f;
+ }
+ if (geomColor4Data)
+ {
+ (*geomColor4Data)[i4] = 0.0f;
+ (*geomColor4Data)[i4 + 1] = 0.0f;
+ (*geomColor4Data)[i4 + 2] = sineData(uv[i2], 6.0f);
+ (*geomColor4Data)[i4 + 3] = 1.0f;
+ }
}
}
}
diff --git a/source/PyMaterialX/PyMaterialXGenOgsXml/PyOgsFragment.cpp b/source/PyMaterialX/PyMaterialXGenOgsXml/PyOgsFragment.cpp
index 3b39749787..c2aeac8a76 100644
--- a/source/PyMaterialX/PyMaterialXGenOgsXml/PyOgsFragment.cpp
+++ b/source/PyMaterialX/PyMaterialXGenOgsXml/PyOgsFragment.cpp
@@ -25,6 +25,7 @@ void bindPyOgsFragment(py::module& mod)
.def_property_readonly("document", &my::OgsFragment::getDocument)
.def_property_readonly("fragmentSource", &my::OgsFragment::getFragmentSource)
.def_property_readonly("fragmentName", &my::OgsFragment::getFragmentName)
+ .def_property_readonly("shader", &my::OgsFragment::getShader)
.def_property_readonly("pathInputMap", &my::OgsFragment::getPathInputMap)
.def_property_readonly("isElementAShader", &my::OgsFragment::isElementAShader)
.def_property_readonly("isTransparent", &my::OgsFragment::isTransparent)