Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
</implementation>

<!-- <hextiledimage> -->
<implementation name="IM_hextiledimage_color3_genmdl" nodedef="ND_hextiledimage_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextiledimage_color3({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}}, {{falloffcontrast}}, {{lumacoeffs}})" target="genmdl">
<implementation name="IM_hextiledimage_color3_genmdl" nodedef="ND_hextiledimage_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextiledimage_color3({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}}, {{falloffcontrast}}, {{lumacoeffs}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="color3" implname="default_value" />
</implementation>
<implementation name="IM_hextiledimage_color4_genmdl" nodedef="ND_hextiledimage_color4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextiledimage_color4({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}}, {{falloffcontrast}}, {{lumacoeffs}})" target="genmdl">
<implementation name="IM_hextiledimage_color4_genmdl" nodedef="ND_hextiledimage_color4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextiledimage_color4({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}}, {{falloffcontrast}}, {{lumacoeffs}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="color4" implname="default_value" />
</implementation>

Expand All @@ -56,7 +56,7 @@
<implementation name="IM_normalmap_vector2_genmdl" nodedef="ND_normalmap_vector2" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_normalmap_vector2(mxp_in:{{in}}, mxp_scale:{{scale}}, mxp_normal:{{normal}}, mxp_tangent:{{tangent}}, mxp_bitangent:{{bitangent}})" target="genmdl" />

<!-- <hextilednormalmap> -->
<implementation name="IM_hextilednormalmap_vector3_genmdl" nodedef="ND_hextilednormalmap_vector3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextilednormalmap_vector3({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}},{{strength}}, {{flip_g}}, {{normal}}, {{tangent}}, {{bitangent}})" target="genmdl">
<implementation name="IM_hextilednormalmap_vector3_genmdl" nodedef="ND_hextilednormalmap_vector3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_hextilednormalmap_vector3({{file}}, {{default}}, {{texcoord}}, {{tiling}}, {{rotation}}, {{rotationrange}}, {{scale}}, {{scalerange}}, {{offset}}, {{offsetrange}}, {{falloff}},{{strength}}, {{flip_g}}, {{normal}}, {{tangent}}, {{bitangent}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="vector3" implname="default_value" />
</implementation>

Expand Down
7 changes: 7 additions & 0 deletions source/MaterialXGenMdl/MdlShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ MdlShaderGenerator::MdlShaderGenerator(TypeSystemPtr typeSystem) :
registerImplementation("IM_image_vector2_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_vector3_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_vector4_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);

// <!-- <hextiledimage> -->
registerImplementation("IM_hextiledimage_color3_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_hextiledimage_color4_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);

// <!-- <hextilednormalmap> -->
registerImplementation("IM_hextilednormalmap_vector3_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
}

void MdlShaderGenerator::applyDefaultOptions(GenOptions& options) const
Expand Down
44 changes: 34 additions & 10 deletions source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ export color mx_hextiledimage_color3(
color mxp_lumacoeffs = color(0.2126, 0.7152, 0.0722)
[[
anno::display_name("Luma Coefficients")
]],
uniform bool mxp_flip_v = false
[[
anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
anno::hidden()
]]
)
[[
Expand All @@ -677,9 +682,12 @@ export color mx_hextiledimage_color3(
);

// lookup texture
color c1 = tex::lookup_color(tex: mxp_file, coord: tile_data.coords[0]);
color c2 = tex::lookup_color(tex: mxp_file, coord: tile_data.coords[1]);
color c3 = tex::lookup_color(tex: mxp_file, coord: tile_data.coords[2]);
float2 coord1 = mxp_flip_v ? float2(tile_data.coords[0].x, 1.0 - tile_data.coords[0].y) : tile_data.coords[0];
float2 coord2 = mxp_flip_v ? float2(tile_data.coords[1].x, 1.0 - tile_data.coords[1].y) : tile_data.coords[1];
float2 coord3 = mxp_flip_v ? float2(tile_data.coords[2].x, 1.0 - tile_data.coords[2].y) : tile_data.coords[2];
color c1 = tex::lookup_color(tex: mxp_file, coord: coord1);
color c2 = tex::lookup_color(tex: mxp_file, coord: coord2);
color c3 = tex::lookup_color(tex: mxp_file, coord: coord3);

// luminance as weight
float3 cw = float3(math::dot(float3(c1), float3(mxp_lumacoeffs)),
Expand Down Expand Up @@ -745,6 +753,11 @@ export core::color4 mx_hextiledimage_color4(
color mxp_lumacoeffs = color(0.2126, 0.7152, 0.0722)
[[
anno::display_name("Luma Coefficients")
]],
uniform bool mxp_flip_v = false
[[
anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
anno::hidden()
]]
)
[[
Expand All @@ -767,9 +780,12 @@ export core::color4 mx_hextiledimage_color4(
);

// lookup texture
core::color4 c1 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: tile_data.coords[0]));
core::color4 c2 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: tile_data.coords[1]));
core::color4 c3 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: tile_data.coords[2]));
float2 coord1 = mxp_flip_v ? float2(tile_data.coords[0].x, 1.0 - tile_data.coords[0].y) : tile_data.coords[0];
float2 coord2 = mxp_flip_v ? float2(tile_data.coords[1].x, 1.0 - tile_data.coords[1].y) : tile_data.coords[1];
float2 coord3 = mxp_flip_v ? float2(tile_data.coords[2].x, 1.0 - tile_data.coords[2].y) : tile_data.coords[2];
core::color4 c1 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: coord1));
core::color4 c2 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: coord2));
core::color4 c3 = core::mk_color4(tex::lookup_float4(tex: mxp_file, coord: coord3));

// luminance as weight
float3 cw = float3(math::dot(float3(c1.rgb), float3(mxp_lumacoeffs)),
Expand Down Expand Up @@ -2455,7 +2471,12 @@ export float3 mx_hextilednormalmap_vector3(
]],
float3 mxp_normal,
float3 mxp_tangent,
float3 mxp_bitangent
float3 mxp_bitangent,
uniform bool mxp_flip_v = false
[[
anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
anno::hidden()
]]
)
[[
anno::description("Node Group: math")
Expand All @@ -2480,9 +2501,12 @@ export float3 mx_hextilednormalmap_vector3(
);

// lookup normalmap
float3 nm1 = tex::lookup_float3(tex: mxp_file, coord: tile_data.coords[0]);
float3 nm2 = tex::lookup_float3(tex: mxp_file, coord: tile_data.coords[1]);
float3 nm3 = tex::lookup_float3(tex: mxp_file, coord: tile_data.coords[2]);
float2 coord1 = mxp_flip_v ? float2(tile_data.coords[0].x, 1.0 - tile_data.coords[0].y) : tile_data.coords[0];
float2 coord2 = mxp_flip_v ? float2(tile_data.coords[1].x, 1.0 - tile_data.coords[1].y) : tile_data.coords[1];
float2 coord3 = mxp_flip_v ? float2(tile_data.coords[2].x, 1.0 - tile_data.coords[2].y) : tile_data.coords[2];
float3 nm1 = tex::lookup_float3(tex: mxp_file, coord: coord1);
float3 nm2 = tex::lookup_float3(tex: mxp_file, coord: coord2);
float3 nm3 = tex::lookup_float3(tex: mxp_file, coord: coord3);
nm1.y = mxp_flip_g ? 1.0 - nm1.y : nm1.y;
nm2.y = mxp_flip_g ? 1.0 - nm2.y : nm2.y;
nm3.y = mxp_flip_g ? 1.0 - nm3.y : nm3.y;
Expand Down
Loading