mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Implement support for ND_open_pbr_surface_surfaceshader exported by Blender v4.5 when using MaterialX. This enables proper parsing and conversion of OpenPBR materials from Blender-exported USD files. Key changes: - Add MtlxOpenPBRSurface struct with all Blender v4.5 parameters in usdMtlx.hh - Implement ReconstructShader specialization for MtlxOpenPBRSurface in prim-reconstruct.cc - Add MaterialXConfigAPI detection and OpenPBR shader attachment in render-data.cc - Implement DumpOpenPBRSurface for material output in render-scene-dump.cc - Add pretty-print support for MtlxOpenPBRSurface in pprinter.cc When MaterialXConfigAPI is present on a Material, the system now: 1. Attempts to parse outputs:mtlx:surface connection 2. Falls back to searching for child Shader prims with OpenPBR info:id 3. Converts MtlxOpenPBRSurface to OpenPBRSurface for rendering Tested with models/cube-materialx.usda and models/suzanne-materialx.usda 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
175 lines
7.4 KiB
Plaintext
Executable File
175 lines
7.4 KiB
Plaintext
Executable File
#usda 1.0
|
|
(
|
|
defaultPrim = "root"
|
|
doc = "Blender v4.5.4 LTS"
|
|
metersPerUnit = 1
|
|
upAxis = "Z"
|
|
)
|
|
|
|
def Xform "root" (
|
|
customData = {
|
|
dictionary Blender = {
|
|
bool generated = 1
|
|
}
|
|
}
|
|
)
|
|
{
|
|
def Xform "Cube"
|
|
{
|
|
custom string userProperties:blender:object_name = "Cube"
|
|
|
|
def Mesh "Cube_001" (
|
|
active = true
|
|
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
)
|
|
{
|
|
uniform bool doubleSided = 1
|
|
float3[] extent = [(-1, -1, -1), (1, 1, 1)]
|
|
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
|
|
int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 7, 6, 6, 7, 5, 4, 4, 5, 1, 0, 2, 6, 4, 0, 7, 3, 1, 5]
|
|
rel material:binding = </root/_materials/Material_003>
|
|
normal3f[] normals = [(-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1)] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
point3f[] points = [(-1, -1, -1), (-1, -1, 1), (-1, 1, -1), (-1, 1, 1), (1, -1, -1), (1, -1, 1), (1, 1, -1), (1, 1, 1)]
|
|
texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.375, 0.25), (0.625, 0.25), (0.625, 0.5), (0.375, 0.5), (0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.125, 0.5), (0.375, 0.5), (0.375, 0.75), (0.125, 0.75), (0.625, 0.5), (0.875, 0.5), (0.875, 0.75), (0.625, 0.75)] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
uniform token subdivisionScheme = "none"
|
|
custom string userProperties:blender:data_name = "Cube.001"
|
|
}
|
|
}
|
|
|
|
def Scope "_materials"
|
|
{
|
|
def Material "Material_003" (
|
|
prepend apiSchemas = ["MaterialXConfigAPI"]
|
|
)
|
|
{
|
|
string config:mtlx:version = "1.39"
|
|
token outputs:mtlx:surface.connect = </root/_materials/Material_003/Principled_BSDF_mtlx1.outputs:surface>
|
|
token outputs:surface.connect = </root/_materials/Material_003/Principled_BSDF.outputs:surface>
|
|
custom string userProperties:blender:data_name = "Material.003"
|
|
|
|
def Shader "Principled_BSDF"
|
|
{
|
|
uniform token info:id = "UsdPreviewSurface"
|
|
float inputs:clearcoat = 0
|
|
float inputs:clearcoatRoughness = 0.03
|
|
color3f inputs:diffuseColor = (0.8, 0.8, 0.8)
|
|
float inputs:ior = 1.5
|
|
float inputs:metallic = 0
|
|
float inputs:opacity = 1
|
|
float inputs:roughness = 0.5
|
|
float inputs:specular = 0.5
|
|
token outputs:surface
|
|
}
|
|
|
|
def Shader "Principled_BSDF_mtlx1"
|
|
{
|
|
uniform token info:id = "ND_open_pbr_surface_surfaceshader"
|
|
color3f inputs:base_color = (0.8, 0.8, 0.8)
|
|
float inputs:base_diffuse_roughness = 0
|
|
float inputs:base_metalness = 0
|
|
float inputs:base_weight = 1
|
|
color3f inputs:coat_color = (1, 1, 1)
|
|
float inputs:coat_darkening
|
|
float inputs:coat_ior = 1.5
|
|
float inputs:coat_roughness = 0.03
|
|
float inputs:coat_roughness_anisotropy
|
|
float inputs:coat_weight = 0
|
|
color3f inputs:emission_color = (1, 1, 1)
|
|
float inputs:emission_luminance = 0
|
|
color3f inputs:fuzz_color = (1, 1, 1)
|
|
float inputs:fuzz_roughness = 0.5
|
|
float inputs:fuzz_weight = 0
|
|
float3 inputs:geometry_coat_normal
|
|
float3 inputs:geometry_coat_tangent
|
|
float3 inputs:geometry_normal
|
|
float inputs:geometry_opacity = 1
|
|
float3 inputs:geometry_tangent.connect = </root/_materials/Material_003/NodeGraphs.outputs:node_003_out>
|
|
bool inputs:geometry_thin_walled
|
|
color3f inputs:specular_color = (1, 1, 1)
|
|
float inputs:specular_ior = 1.5
|
|
float inputs:specular_roughness = 0.5
|
|
float inputs:specular_roughness_anisotropy = 0
|
|
float inputs:specular_weight = 1
|
|
color3f inputs:subsurface_color = (0.8, 0.8, 0.8)
|
|
float inputs:subsurface_radius = 0.05
|
|
color3f inputs:subsurface_radius_scale = (1, 0.2, 0.1)
|
|
float inputs:subsurface_scatter_anisotropy = 0
|
|
float inputs:subsurface_weight = 0
|
|
float inputs:thin_film_ior = 1.33
|
|
float inputs:thin_film_thickness = 0
|
|
float inputs:thin_film_weight = 0
|
|
color3f inputs:transmission_color = (0.8, 0.8, 0.8)
|
|
float inputs:transmission_depth
|
|
float inputs:transmission_dispersion_abbe_number
|
|
float inputs:transmission_dispersion_scale
|
|
color3f inputs:transmission_scatter
|
|
float inputs:transmission_scatter_anisotropy
|
|
float inputs:transmission_weight = 0
|
|
token outputs:surface
|
|
}
|
|
|
|
def NodeGraph "NodeGraphs"
|
|
{
|
|
float3 outputs:node_003_out.connect = </root/_materials/Material_003/NodeGraphs/node_003.outputs:out>
|
|
|
|
def Shader "node"
|
|
{
|
|
uniform token info:id = "ND_normal_vector3"
|
|
string inputs:space = "world"
|
|
float3 outputs:out
|
|
}
|
|
|
|
def Shader "node_001"
|
|
{
|
|
uniform token info:id = "ND_normalize_vector3"
|
|
float3 inputs:in.connect = </root/_materials/Material_003/NodeGraphs/node.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
|
|
def Shader "node_002"
|
|
{
|
|
uniform token info:id = "ND_tangent_vector3"
|
|
string inputs:space = "world"
|
|
float3 outputs:out
|
|
}
|
|
|
|
def Shader "node_003"
|
|
{
|
|
uniform token info:id = "ND_normalize_vector3"
|
|
float3 inputs:in.connect = </root/_materials/Material_003/NodeGraphs/node_002.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
|
|
def Shader "node_004"
|
|
{
|
|
uniform token info:id = "ND_rotate3d_vector3"
|
|
float inputs:amount = -90
|
|
float3 inputs:axis.connect = </root/_materials/Material_003/NodeGraphs/node_001.outputs:out>
|
|
float3 inputs:in.connect = </root/_materials/Material_003/NodeGraphs/node_003.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
|
|
def Shader "node_005"
|
|
{
|
|
uniform token info:id = "ND_normalize_vector3"
|
|
float3 inputs:in.connect = </root/_materials/Material_003/NodeGraphs/node_004.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def DomeLight "env_light"
|
|
{
|
|
float inputs:intensity = 1
|
|
asset inputs:texture:file = @.\textures\color_121212.hdr@
|
|
float3 xformOp:rotateXYZ = (90, 1.2722219e-14, 90)
|
|
uniform token[] xformOpOrder = ["xformOp:rotateXYZ"]
|
|
}
|
|
}
|
|
|