forked from bartvdbraak/blender
Cleanup: format
This commit is contained in:
parent
0652945dbd
commit
6a5ab77dcc
@ -214,7 +214,8 @@ void create_usd_preview_surface_material(const USDExporterContext &usd_export_co
|
|||||||
/* Set opacityThreshold if an alpha cutout is used. */
|
/* Set opacityThreshold if an alpha cutout is used. */
|
||||||
if (has_opacity) {
|
if (has_opacity) {
|
||||||
if ((material->blend_method == MA_BM_CLIP) && (material->alpha_threshold > 0.0)) {
|
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));
|
opacity_threshold_input.GetAttr().Set(pxr::VtValue(material->alpha_threshold));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,8 @@ class USDExportTest(AbstractUSDTest):
|
|||||||
shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF")
|
shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF")
|
||||||
shader = UsdShade.Shader(shader_prim)
|
shader = UsdShade.Shader(shader_prim)
|
||||||
opacity_input = shader.GetInput('opacity')
|
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")
|
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.
|
# 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']
|
bsdf = mat.node_tree.nodes['Principled BSDF']
|
||||||
tex_output = bsdf.inputs['Base Color'].links[0].from_node.outputs['Color']
|
tex_output = bsdf.inputs['Base Color'].links[0].from_node.outputs['Color']
|
||||||
alpha_input = bsdf.inputs['Alpha']
|
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'].blend_method = 'CLIP'
|
||||||
bpy.data.materials['Material'].alpha_threshold = 0.01
|
bpy.data.materials['Material'].alpha_threshold = 0.01
|
||||||
export_path = self.tempdir / "alphaclip_material.usda"
|
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.assertEqual(opacity_input.HasConnectedSource(), True, "Alpha input should be connected")
|
||||||
self.assertGreater(opacity_thres_input.Get(), 0.0, "Opacity threshold input should be > 0")
|
self.assertGreater(opacity_thres_input.Get(), 0.0, "Opacity threshold input should be > 0")
|
||||||
|
|
||||||
|
|
||||||
# Modify material again, this time with alpha blend.
|
# Modify material again, this time with alpha blend.
|
||||||
bpy.data.materials['Material'].blend_method = 'BLEND'
|
bpy.data.materials['Material'].blend_method = 'BLEND'
|
||||||
export_path = self.tempdir / "alphablend_material.usda"
|
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_input.HasConnectedSource(), True, "Alpha input should be connected")
|
||||||
self.assertEqual(opacity_thres_input.Get(), None, "Opacity threshold should not be specified for alpha blend")
|
self.assertEqual(opacity_thres_input.Get(), None, "Opacity threshold should not be specified for alpha blend")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global args
|
global args
|
||||||
import argparse
|
import argparse
|
||||||
|
Loading…
Reference in New Issue
Block a user