mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
- mtlx-normalmap-plane.usda: Changed faceVertexIndices from [0,1,2,3] to [0,3,2,1] - mtlx-normalmap-multi.usda: Fixed plane meshes winding order (cubes were already correct) The CCW winding [0,3,2,1] produces face normals pointing UP (+Y) matching the declared vertex normals, ensuring correct front-face rendering. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
171 lines
6.6 KiB
Plaintext
171 lines
6.6 KiB
Plaintext
#usda 1.0
|
|
(
|
|
doc = "MaterialX Normal Map Test - Cube Geometry"
|
|
metersPerUnit = 1
|
|
upAxis = "Y"
|
|
defaultPrim = "World"
|
|
)
|
|
|
|
def Xform "World"
|
|
{
|
|
def Mesh "NormalMapCube" (
|
|
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 = </World/_materials/NormalMapMaterial>
|
|
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, 0), (1, 0), (1, 1), (0, 1),
|
|
(0, 0), (1, 0), (1, 1), (0, 1),
|
|
(0, 0), (1, 0), (1, 1), (0, 1),
|
|
(0, 0), (1, 0), (1, 1), (0, 1),
|
|
(0, 0), (1, 0), (1, 1), (0, 1),
|
|
(0, 0), (1, 0), (1, 1), (0, 1)
|
|
] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
uniform token subdivisionScheme = "none"
|
|
}
|
|
|
|
def Scope "_materials"
|
|
{
|
|
def Material "NormalMapMaterial" (
|
|
prepend apiSchemas = ["MaterialXConfigAPI"]
|
|
)
|
|
{
|
|
string config:mtlx:version = "1.39"
|
|
token outputs:mtlx:surface.connect = </World/_materials/NormalMapMaterial/OpenPBRShader.outputs:surface>
|
|
token outputs:surface.connect = </World/_materials/NormalMapMaterial/FallbackShader.outputs:surface>
|
|
|
|
# OpenPBR Surface Shader with normal map
|
|
def Shader "OpenPBRShader"
|
|
{
|
|
uniform token info:id = "ND_open_pbr_surface_surfaceshader"
|
|
color3f inputs:base_color = (0.8, 0.75, 0.7)
|
|
float inputs:base_weight = 1.0
|
|
float inputs:base_metalness = 0.0
|
|
float inputs:base_diffuse_roughness = 0.0
|
|
float inputs:specular_weight = 1.0
|
|
float inputs:specular_roughness = 0.35
|
|
float inputs:specular_ior = 1.5
|
|
float3 inputs:geometry_normal.connect = </World/_materials/NormalMapMaterial/NodeGraph.outputs:normal_out>
|
|
float3 inputs:geometry_tangent.connect = </World/_materials/NormalMapMaterial/NodeGraph.outputs:tangent_out>
|
|
token outputs:surface
|
|
}
|
|
|
|
# Fallback UsdPreviewSurface
|
|
def Shader "FallbackShader"
|
|
{
|
|
uniform token info:id = "UsdPreviewSurface"
|
|
color3f inputs:diffuseColor = (0.8, 0.75, 0.7)
|
|
float inputs:roughness = 0.35
|
|
float inputs:metallic = 0.0
|
|
normal3f inputs:normal.connect = </World/_materials/NormalMapMaterial/FallbackNormalTexture.outputs:rgb>
|
|
token outputs:surface
|
|
}
|
|
|
|
def Shader "FallbackNormalTexture"
|
|
{
|
|
uniform token info:id = "UsdUVTexture"
|
|
asset inputs:file = @./textures/normalmap-bumps.png@ (
|
|
colorSpace = "raw"
|
|
)
|
|
token inputs:sourceColorSpace = "raw"
|
|
float2 inputs:st.connect = </World/_materials/NormalMapMaterial/FallbackTexCoord.outputs:result>
|
|
float4 inputs:scale = (2.0, 2.0, 2.0, 1.0)
|
|
float4 inputs:bias = (-1.0, -1.0, -1.0, 0.0)
|
|
float3 outputs:rgb
|
|
}
|
|
|
|
def Shader "FallbackTexCoord"
|
|
{
|
|
uniform token info:id = "UsdPrimvarReader_float2"
|
|
string inputs:varname = "st"
|
|
float2 outputs:result
|
|
}
|
|
|
|
# MaterialX NodeGraph for normal/tangent handling
|
|
def NodeGraph "NodeGraph"
|
|
{
|
|
float3 outputs:normal_out.connect = </World/_materials/NormalMapMaterial/NodeGraph/NormalMapNode.outputs:out>
|
|
float3 outputs:tangent_out.connect = </World/_materials/NormalMapMaterial/NodeGraph/TangentNormalize.outputs:out>
|
|
|
|
# Read UV coordinates
|
|
def Shader "TexCoord"
|
|
{
|
|
uniform token info:id = "ND_texcoord_vector2"
|
|
int inputs:index = 0
|
|
float2 outputs:out
|
|
}
|
|
|
|
# Load normal map texture as vector3
|
|
def Shader "NormalMapTexture"
|
|
{
|
|
uniform token info:id = "ND_image_vector3"
|
|
asset inputs:file = @./textures/normalmap-bumps.png@ (
|
|
colorSpace = "raw"
|
|
)
|
|
float2 inputs:texcoord.connect = </World/_materials/NormalMapMaterial/NodeGraph/TexCoord.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
|
|
# Convert tangent space normal to world space
|
|
def Shader "NormalMapNode"
|
|
{
|
|
uniform token info:id = "ND_normalmap_float"
|
|
float3 inputs:in.connect = </World/_materials/NormalMapMaterial/NodeGraph/NormalMapTexture.outputs:out>
|
|
float inputs:scale = 1.0
|
|
float3 outputs:out
|
|
}
|
|
|
|
# Get world space tangent
|
|
def Shader "TangentNode"
|
|
{
|
|
uniform token info:id = "ND_tangent_vector3"
|
|
string inputs:space = "world"
|
|
float3 outputs:out
|
|
}
|
|
|
|
# Normalize tangent
|
|
def Shader "TangentNormalize"
|
|
{
|
|
uniform token info:id = "ND_normalize_vector3"
|
|
float3 inputs:in.connect = </World/_materials/NormalMapMaterial/NodeGraph/TangentNode.outputs:out>
|
|
float3 outputs:out
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# Lighting
|
|
def DomeLight "EnvLight"
|
|
{
|
|
float inputs:intensity = 1.0
|
|
asset inputs:texture:file = @./textures/env_studio_default.hdr@
|
|
}
|
|
|
|
def DistantLight "KeyLight"
|
|
{
|
|
float inputs:intensity = 2.0
|
|
float3 xformOp:rotateXYZ = (-45, 30, 0)
|
|
uniform token[] xformOpOrder = ["xformOp:rotateXYZ"]
|
|
}
|
|
}
|