From 88b335aa0fac6a3745a97ed2ece084f3e869adb4 Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Fri, 8 Mar 2024 23:23:58 +0100 Subject: [PATCH] Fix #98572: handle the 'mirror' texture wrap mode for USD materials Support for the texture extension mode of "mirror" was simply missed from `925fb66693d`. With this patch, #98572 should be completely fixed. Pull Request: https://projects.blender.org/blender/blender/pulls/118947 --- source/blender/io/usd/intern/usd_reader_material.cc | 5 +++++ source/blender/io/usd/intern/usd_writer_material.cc | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index 1f0217583b0..6fdf561de3b 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -74,6 +74,7 @@ static const pxr::TfToken RAW("RAW", pxr::TfToken::Immortal); static const pxr::TfToken black("black", pxr::TfToken::Immortal); static const pxr::TfToken clamp("clamp", pxr::TfToken::Immortal); static const pxr::TfToken repeat("repeat", pxr::TfToken::Immortal); +static const pxr::TfToken mirror("mirror", pxr::TfToken::Immortal); static const pxr::TfToken wrapS("wrapS", pxr::TfToken::Immortal); static const pxr::TfToken wrapT("wrapT", pxr::TfToken::Immortal); @@ -332,6 +333,10 @@ static int get_image_extension(const pxr::UsdShadeShader &usd_shader, const int return SHD_IMAGE_EXTENSION_CLIP; } + if (wrap_val == usdtokens::mirror) { + return SHD_IMAGE_EXTENSION_MIRROR; + } + return default_value; } diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index 1c2127e65fc..5e566a4481b 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -80,6 +80,7 @@ static const pxr::TfToken Shader("Shader", pxr::TfToken::Immortal); static const pxr::TfToken black("black", pxr::TfToken::Immortal); static const pxr::TfToken clamp("clamp", pxr::TfToken::Immortal); static const pxr::TfToken repeat("repeat", pxr::TfToken::Immortal); +static const pxr::TfToken mirror("mirror", pxr::TfToken::Immortal); static const pxr::TfToken wrapS("wrapS", pxr::TfToken::Immortal); static const pxr::TfToken wrapT("wrapT", pxr::TfToken::Immortal); static const pxr::TfToken in("in", pxr::TfToken::Immortal); @@ -697,6 +698,9 @@ static pxr::TfToken get_node_tex_image_wrap(bNode *node) case SHD_IMAGE_EXTENSION_CLIP: wrap = usdtokens::black; break; + case SHD_IMAGE_EXTENSION_MIRROR: + wrap = usdtokens::mirror; + break; } return wrap;