diff --git a/src/guc/main.c b/src/guc/main.c index 893d76e..7bafd20 100644 --- a/src/guc/main.c +++ b/src/guc/main.c @@ -40,13 +40,6 @@ static struct cag_option cmd_options[] = { .value_name = NULL, .description = "Convert and inline MaterialX materials into the USD layer using UsdMtlx" }, - { - .identifier = 'c', - .access_letters = "c", - .access_name = "hdstorm-compat", - .value_name = NULL, - .description = "Apply compatibility tweaks for the USD Storm Hydra render delegate" - }, { .identifier = 'v', .access_letters = "v", @@ -75,7 +68,6 @@ int main(int argc, char* argv[]) struct guc_options options = { .emit_mtlx = false, .mtlx_as_usdshade = false, - .hdstorm_compat = false, .default_material_variant = 0 }; @@ -91,9 +83,6 @@ int main(int argc, char* argv[]) case 'u': options.mtlx_as_usdshade = true; break; - case 'c': - options.hdstorm_compat = true; - break; case 'v': { const char* value = cag_option_get_value(&context); options.default_material_variant = atoi(value); // fall back to 0 on error diff --git a/src/libguc/include/guc.h b/src/libguc/include/guc.h index dbcb40f..4eea762 100644 --- a/src/libguc/include/guc.h +++ b/src/libguc/include/guc.h @@ -37,9 +37,6 @@ struct guc_options // versions. bool mtlx_as_usdshade; - // Workaround to make hdStorm recognize alpha materials as translucent. - bool hdstorm_compat; - // If the asset supports the KHR_materials_variants extension, select the material // variant at the given index by default. int default_material_variant; diff --git a/src/libguc/src/converter.cpp b/src/libguc/src/converter.cpp index 964fb0c..fe98f6b 100644 --- a/src/libguc/src/converter.cpp +++ b/src/libguc/src/converter.cpp @@ -210,7 +210,7 @@ namespace guc , m_stage(stage) , m_params(params) , m_mtlxDoc(mx::createDocument()) - , m_mtlxConverter(m_mtlxDoc, m_imgMetadata, params.hdStormCompat) + , m_mtlxConverter(m_mtlxDoc, m_imgMetadata) , m_usdPreviewSurfaceConverter(m_stage, m_imgMetadata) { } diff --git a/src/libguc/src/converter.h b/src/libguc/src/converter.h index d6abe3e..fd944d7 100644 --- a/src/libguc/src/converter.h +++ b/src/libguc/src/converter.h @@ -46,7 +46,6 @@ namespace guc bool genRelativePaths; bool emitMtlx; bool mtlxAsUsdShade; - bool hdStormCompat; int defaultMaterialVariant; }; diff --git a/src/libguc/src/fileFormat.cpp b/src/libguc/src/fileFormat.cpp index d723717..10dca90 100644 --- a/src/libguc/src/fileFormat.cpp +++ b/src/libguc/src/fileFormat.cpp @@ -145,7 +145,6 @@ bool UsdGlTFFileFormat::Read(SdfLayer* layer, params.genRelativePaths = false; params.emitMtlx = data->emitMtlx; params.mtlxAsUsdShade = true; - params.hdStormCompat = false; params.defaultMaterialVariant = 0; SdfLayerRefPtr tmpLayer = SdfLayer::CreateAnonymous(".usdc"); diff --git a/src/libguc/src/guc.cpp b/src/libguc/src/guc.cpp index 4cd1c6f..fe083a8 100644 --- a/src/libguc/src/guc.cpp +++ b/src/libguc/src/guc.cpp @@ -55,7 +55,6 @@ bool convertToUsd(fs::path src_dir, params.genRelativePaths = true; params.emitMtlx = options->emit_mtlx; params.mtlxAsUsdShade = options->mtlx_as_usdshade; - params.hdStormCompat = options->hdstorm_compat; params.defaultMaterialVariant = options->default_material_variant; Converter converter(gltf_data, stage, params); diff --git a/src/libguc/src/materialx.cpp b/src/libguc/src/materialx.cpp index 2772c9e..f1ec31a 100644 --- a/src/libguc/src/materialx.cpp +++ b/src/libguc/src/materialx.cpp @@ -267,13 +267,11 @@ namespace detail namespace guc { MaterialXMaterialConverter::MaterialXMaterialConverter(mx::DocumentPtr doc, - const ImageMetadataMap& imageMetadataMap, - bool hdstorm_compat) + const ImageMetadataMap& imageMetadataMap) : m_doc(doc) , m_imageMetadataMap(imageMetadataMap) , m_defaultColorSetName(makeColorSetName(0)) , m_defaultOpacitySetName(makeOpacitySetName(0)) - , m_hdstormCompat(hdstorm_compat) { } @@ -490,20 +488,6 @@ namespace guc auto sheenRoughnessFactorDefault = 0.0f; // according to spec addFloatTextureInput(nodeGraph, shaderNode, "sheen_roughness", sheen->sheen_roughness_texture, 3, sheen->sheen_roughness_factor, sheenRoughnessFactorDefault); } - - // Unfortunately, hdStorm blending is messed up because the material is not flagged as 'translucent': - // https://github.com/PixarAnimationStudios/USD/blob/db8e3266dcaa24aa26b7201bc20ff4d8e81448d6/pxr/imaging/hdSt/materialXFilter.cpp#L441-L507 - // For alpha materials, set a non-zero transmission input to make the renderer believe that we are a translucent Standard Surface. - if (material->alpha_mode != cgltf_alpha_mode_opaque && m_hdstormCompat) - { - mx::InputPtr transmissionInput = material->has_transmission ? shaderNode->getInput("transmission") : shaderNode->addInput("transmission", MTLX_TYPE_FLOAT); - - if (!transmissionInput->hasValue() || (transmissionInput->getValue()->isA() && transmissionInput->getValue()->asA() == 0.0f)) - { - float valueCloseToZero = 0.00001f; - transmissionInput->setValue(valueCloseToZero); - } - } } void MaterialXMaterialConverter::addDiffuseTextureInput(mx::NodeGraphPtr nodeGraph, @@ -934,18 +918,7 @@ namespace guc if (texValueType != MTLX_TYPE_FLOAT) { - bool remapChannelToAlpha = false; - - // USD probably handles greyscale+alpha textures like it does for the UsdPreviewSurface spec: - // "If a two-channel texture is fed into a UsdUVTexture, the r, g, and b components of the rgb output will - // repeat the first channel's value, while the single a output will be set to the second channel's value." - if (m_hdstormCompat) - { - int channelCount = getTextureChannelCount(textureView); - remapChannelToAlpha = (channelCount == 2 && channelIndex == 1); - } - - valueNode = detail::makeExtractChannelNode(nodeGraph, valueNode, remapChannelToAlpha ? 3 : channelIndex); + valueNode = detail::makeExtractChannelNode(nodeGraph, valueNode, channelIndex); } return valueNode; @@ -1218,15 +1191,13 @@ namespace guc int channelCount = metadata.channelCount; - if (channelCount == 3 || (m_hdstormCompat && channelCount == 1)) + if (channelCount == 4) { - // USD promotes single-channel textures to RGB - return color ? MTLX_TYPE_COLOR3 : MTLX_TYPE_VECTOR3; + return color ? MTLX_TYPE_COLOR4 : MTLX_TYPE_VECTOR4; } - else if (channelCount == 4 || (m_hdstormCompat && channelCount == 2)) + else if (channelCount == 3) { - // And for greyscale-alpha textures, to RGBA (with vec2[1] being alpha) - return color ? MTLX_TYPE_COLOR4 : MTLX_TYPE_VECTOR4; + return color ? MTLX_TYPE_COLOR3 : MTLX_TYPE_VECTOR3; } else if (channelCount == 2) { diff --git a/src/libguc/src/materialx.h b/src/libguc/src/materialx.h index 222fe55..fd74fd1 100644 --- a/src/libguc/src/materialx.h +++ b/src/libguc/src/materialx.h @@ -30,8 +30,7 @@ namespace guc { public: MaterialXMaterialConverter(mx::DocumentPtr doc, - const ImageMetadataMap& imageMetadataMap, - bool hdstormCompat); + const ImageMetadataMap& imageMetadataMap); void convert(const cgltf_material* material, const std::string& materialName); @@ -41,8 +40,6 @@ namespace guc std::string m_defaultColorSetName; std::string m_defaultOpacitySetName; - bool m_hdstormCompat; - private: void createUnlitSurfaceNodes(const cgltf_material* material, const std::string& materialName);