Skip to content
Snippets Groups Projects
Commit f2d15d4f authored by Michael Kowalski's avatar Michael Kowalski Committed by Gitea
Browse files

Fix: USD: Wrong UsdUVTexture rgb output type.

This fixes a bug where the rgb UsdUVTexture shader output
attributes were created with incorrect type color3f when
connected to UsdPreviewSurface diffuseColor and emissiveColor
inputs. The UsdPreviewSurface specification requires the
UsdUVTexture rgb output to be of type float3.

This was happening because the UsdUVTexture outputs were created
implicitly by the call to UsdShadeInput::ConnectToSource().  I.e.,
because the diffuseColor and emissiveColor inputs are of type
color3f, this was the type assigned by default to the rgb source
attributes as well.

Now explicitly creating the UsdUVTexture shader output attributes
with the correct types.

Pull Request: https://projects.blender.org/blender/blender/pulls/114728
parent c688b038
No related branches found
No related tags found
No related merge requests found
...@@ -174,16 +174,17 @@ static void create_usd_preview_surface_material(const USDExporterContext &usd_ex ...@@ -174,16 +174,17 @@ static void create_usd_preview_surface_material(const USDExporterContext &usd_ex
pxr::UsdShadeShader usd_shader = create_usd_preview_shader( pxr::UsdShadeShader usd_shader = create_usd_preview_shader(
usd_export_context, usd_material, input_node); usd_export_context, usd_material, input_node);
/* Determine the name of the USD texture node attribute that should be /* Create the UsdUVTexture node output attribute that should be connected to this input. */
* connected to this input. */
pxr::TfToken source_name; pxr::TfToken source_name;
if (input_spec.input_type == pxr::SdfValueTypeNames->Float) { if (input_spec.input_type == pxr::SdfValueTypeNames->Float) {
/* If the input is a float, we connect it to either the texture alpha or red channels. */ /* If the input is a float, we connect it to either the texture alpha or red channels. */
source_name = STREQ(input_link->fromsock->identifier, "Alpha") ? usdtokens::a : source_name = STREQ(input_link->fromsock->identifier, "Alpha") ? usdtokens::a :
usdtokens::r; usdtokens::r;
usd_shader.CreateOutput(source_name, pxr::SdfValueTypeNames->Float);
} }
else { else {
source_name = usdtokens::rgb; source_name = usdtokens::rgb;
usd_shader.CreateOutput(usdtokens::rgb, pxr::SdfValueTypeNames->Float3);
} }
/* Create the preview surface input and connect it to the shader. */ /* Create the preview surface input and connect it to the shader. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment