Cleanup: format

This commit is contained in:
Campbell Barton 2023-05-02 08:41:10 +10:00
parent 0652945dbd
commit 6a5ab77dcc
2 changed files with 6 additions and 4 deletions

View File

@ -214,7 +214,8 @@ void create_usd_preview_surface_material(const USDExporterContext &usd_export_co
/* Set opacityThreshold if an alpha cutout is used. */
if (has_opacity) {
if ((material->blend_method == MA_BM_CLIP) && (material->alpha_threshold > 0.0)) {
pxr::UsdShadeInput opacity_threshold_input = preview_surface.CreateInput(usdtokens::opacityThreshold, pxr::SdfValueTypeNames->Float);
pxr::UsdShadeInput opacity_threshold_input = preview_surface.CreateInput(
usdtokens::opacityThreshold, pxr::SdfValueTypeNames->Float);
opacity_threshold_input.GetAttr().Set(pxr::VtValue(material->alpha_threshold));
}
}

View File

@ -144,7 +144,8 @@ class USDExportTest(AbstractUSDTest):
shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF")
shader = UsdShade.Shader(shader_prim)
opacity_input = shader.GetInput('opacity')
self.assertEqual(opacity_input.HasConnectedSource(), False, "Opacity input should not be connected for opaque material")
self.assertEqual(opacity_input.HasConnectedSource(), False,
"Opacity input should not be connected for opaque material")
self.assertAlmostEqual(opacity_input.Get(), 1.0, "Opacity input should be set to 1")
# The material already has a texture input to the Base Color.
@ -154,7 +155,7 @@ class USDExportTest(AbstractUSDTest):
bsdf = mat.node_tree.nodes['Principled BSDF']
tex_output = bsdf.inputs['Base Color'].links[0].from_node.outputs['Color']
alpha_input = bsdf.inputs['Alpha']
mat.node_tree.links.new(tex_output,alpha_input)
mat.node_tree.links.new(tex_output, alpha_input)
bpy.data.materials['Material'].blend_method = 'CLIP'
bpy.data.materials['Material'].alpha_threshold = 0.01
export_path = self.tempdir / "alphaclip_material.usda"
@ -174,7 +175,6 @@ class USDExportTest(AbstractUSDTest):
self.assertEqual(opacity_input.HasConnectedSource(), True, "Alpha input should be connected")
self.assertGreater(opacity_thres_input.Get(), 0.0, "Opacity threshold input should be > 0")
# Modify material again, this time with alpha blend.
bpy.data.materials['Material'].blend_method = 'BLEND'
export_path = self.tempdir / "alphablend_material.usda"
@ -194,6 +194,7 @@ class USDExportTest(AbstractUSDTest):
self.assertEqual(opacity_input.HasConnectedSource(), True, "Alpha input should be connected")
self.assertEqual(opacity_thres_input.Get(), None, "Opacity threshold should not be specified for alpha blend")
def main():
global args
import argparse