diff --git a/models/mtlx-normalmap-cube.usda b/models/mtlx-normalmap-cube.usda new file mode 100644 index 00000000..b1615d6b --- /dev/null +++ b/models/mtlx-normalmap-cube.usda @@ -0,0 +1,170 @@ +#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 = + 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 = + token outputs:surface.connect = + + # 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 = + float3 inputs:geometry_tangent.connect = + 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 = + 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 = + 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 = + float3 outputs:tangent_out.connect = + + # 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 = + float3 outputs:out + } + + # Convert tangent space normal to world space + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + 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 = + 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"] + } +} diff --git a/models/mtlx-normalmap-multi.usda b/models/mtlx-normalmap-multi.usda new file mode 100644 index 00000000..ce81da3a --- /dev/null +++ b/models/mtlx-normalmap-multi.usda @@ -0,0 +1,544 @@ +#usda 1.0 +( + doc = "MaterialX Normal Map Test - Comprehensive Multi-Geometry Scene" + metersPerUnit = 1 + upAxis = "Y" + defaultPrim = "World" +) + +def Xform "World" +{ + # Row 1: Planes with all three normal maps + def Xform "Planes" + { + double3 xformOp:translate = (0, 0, 3) + uniform token[] xformOpOrder = ["xformOp:translate"] + + def Mesh "Plane_Bumps" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (-3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Mesh "Plane_Gradient" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (0, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Mesh "Plane_Bricks" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + } + + # Row 2: Cubes with all three normal maps + def Xform "Cubes" + { + double3 xformOp:translate = (0, 1, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + + def Mesh "Cube_Bumps" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 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 = + 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 = [ + (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), + (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5) + ] + 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" + double3 xformOp:translate = (-3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Mesh "Cube_Gradient" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 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 = + 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 = [ + (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), + (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5) + ] + 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" + double3 xformOp:translate = (0, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Mesh "Cube_Bricks" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 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 = + 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 = [ + (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), + (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5) + ] + 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" + double3 xformOp:translate = (3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + } + + # Row 3: Spheres with all three normal maps + def Xform "Spheres" + { + double3 xformOp:translate = (0, 1, -3) + uniform token[] xformOpOrder = ["xformOp:translate"] + + def Sphere "Sphere_Bumps" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + double radius = 0.8 + rel material:binding = + double3 xformOp:translate = (-3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Sphere "Sphere_Gradient" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + double radius = 0.8 + rel material:binding = + double3 xformOp:translate = (0, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + def Sphere "Sphere_Bricks" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + double radius = 0.8 + rel material:binding = + double3 xformOp:translate = (3, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + } + + # Materials + def Scope "_materials" + { + # Material with bumps normal map + def Material "Mat_Bumps" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.8, 0.8, 0.8) + float inputs:base_weight = 1.0 + float inputs:base_metalness = 0.0 + float inputs:specular_weight = 1.0 + float inputs:specular_roughness = 0.3 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.8, 0.8, 0.8) + float inputs:roughness = 0.3 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTex" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-bumps.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 + } + + def NodeGraph "NodeGraph" + { + float3 outputs:normal_out.connect = + float3 outputs:tangent_out.connect = + + def Shader "TexCoord" + { + uniform token info:id = "ND_texcoord_vector2" + int inputs:index = 0 + float2 outputs:out + } + + def Shader "NormalMapTexture" + { + uniform token info:id = "ND_image_vector3" + asset inputs:file = @./textures/normalmap-bumps.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + float inputs:scale = 1.0 + float3 outputs:out + } + + def Shader "TangentNode" + { + uniform token info:id = "ND_tangent_vector3" + string inputs:space = "world" + float3 outputs:out + } + + def Shader "TangentNormalize" + { + uniform token info:id = "ND_normalize_vector3" + float3 inputs:in.connect = + float3 outputs:out + } + } + } + + # Material with gradient normal map + def Material "Mat_Gradient" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.6, 0.8, 0.6) + float inputs:base_weight = 1.0 + float inputs:base_metalness = 0.0 + float inputs:specular_weight = 1.0 + float inputs:specular_roughness = 0.2 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.6, 0.8, 0.6) + float inputs:roughness = 0.2 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTex" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-gradient.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 + } + + def NodeGraph "NodeGraph" + { + float3 outputs:normal_out.connect = + float3 outputs:tangent_out.connect = + + def Shader "TexCoord" + { + uniform token info:id = "ND_texcoord_vector2" + int inputs:index = 0 + float2 outputs:out + } + + def Shader "NormalMapTexture" + { + uniform token info:id = "ND_image_vector3" + asset inputs:file = @./textures/normalmap-gradient.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + float inputs:scale = 1.0 + float3 outputs:out + } + + def Shader "TangentNode" + { + uniform token info:id = "ND_tangent_vector3" + string inputs:space = "world" + float3 outputs:out + } + + def Shader "TangentNormalize" + { + uniform token info:id = "ND_normalize_vector3" + float3 inputs:in.connect = + float3 outputs:out + } + } + } + + # Material with bricks normal map + def Material "Mat_Bricks" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.7, 0.4, 0.3) + float inputs:base_weight = 1.0 + float inputs:base_metalness = 0.0 + float inputs:specular_weight = 0.5 + float inputs:specular_roughness = 0.6 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.7, 0.4, 0.3) + float inputs:roughness = 0.6 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTex" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-bricks.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 + } + + def NodeGraph "NodeGraph" + { + float3 outputs:normal_out.connect = + float3 outputs:tangent_out.connect = + + def Shader "TexCoord" + { + uniform token info:id = "ND_texcoord_vector2" + int inputs:index = 0 + float2 outputs:out + } + + def Shader "NormalMapTexture" + { + uniform token info:id = "ND_image_vector3" + asset inputs:file = @./textures/normalmap-bricks.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + float inputs:scale = 1.0 + float3 outputs:out + } + + def Shader "TangentNode" + { + uniform token info:id = "ND_tangent_vector3" + string inputs:space = "world" + float3 outputs:out + } + + def Shader "TangentNormalize" + { + uniform token info:id = "ND_normalize_vector3" + float3 inputs:in.connect = + 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"] + } +} diff --git a/models/mtlx-normalmap-plane.usda b/models/mtlx-normalmap-plane.usda new file mode 100644 index 00000000..eefaebe5 --- /dev/null +++ b/models/mtlx-normalmap-plane.usda @@ -0,0 +1,404 @@ +#usda 1.0 +( + doc = "MaterialX Normal Map Test - Plane Geometry" + metersPerUnit = 1 + upAxis = "Y" + defaultPrim = "World" +) + +def Xform "World" +{ + def Xform "Planes" + { + # Plane with bumps normal map + def Mesh "Plane_Bumps" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + float3[] extent = [(-1, 0, -1), (1, 0, 1)] + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (0, 1), (1, 1), (1, 0)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (-2.5, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + # Plane with gradient normal map + def Mesh "Plane_Gradient" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + float3[] extent = [(-1, 0, -1), (1, 0, 1)] + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (0, 1), (1, 1), (1, 0)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (0, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + + # Plane with bricks normal map + def Mesh "Plane_Bricks" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + uniform bool doubleSided = 1 + float3[] extent = [(-1, 0, -1), (1, 0, 1)] + int[] faceVertexCounts = [4] + int[] faceVertexIndices = [0, 3, 2, 1] + rel material:binding = + normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( + interpolation = "faceVarying" + ) + point3f[] points = [(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1)] + texCoord2f[] primvars:st = [(0, 0), (0, 1), (1, 1), (1, 0)] ( + interpolation = "faceVarying" + ) + uniform token subdivisionScheme = "none" + double3 xformOp:translate = (2.5, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] + } + } + + def Scope "_materials" + { + # Material with bumps normal map + def Material "NormalMapMaterial_Bumps" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + # OpenPBR Surface Shader + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.8, 0.8, 0.8) + 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.3 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + # Fallback UsdPreviewSurface + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.8, 0.8, 0.8) + float inputs:roughness = 0.3 + float inputs:metallic = 0.0 + normal3f inputs:normal.connect = + 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 = + 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 = + float3 outputs:tangent_out.connect = + + # 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 = + float3 outputs:out + } + + # Convert tangent space normal to world space + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + 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 = + float3 outputs:out + } + } + } + + # Material with gradient normal map + def Material "NormalMapMaterial_Gradient" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.6, 0.8, 0.6) + 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.2 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.6, 0.8, 0.6) + float inputs:roughness = 0.2 + float inputs:metallic = 0.0 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTexture" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-gradient.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 + } + + def NodeGraph "NodeGraph" + { + float3 outputs:normal_out.connect = + float3 outputs:tangent_out.connect = + + def Shader "TexCoord" + { + uniform token info:id = "ND_texcoord_vector2" + int inputs:index = 0 + float2 outputs:out + } + + def Shader "NormalMapTexture" + { + uniform token info:id = "ND_image_vector3" + asset inputs:file = @./textures/normalmap-gradient.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + float inputs:scale = 1.0 + float3 outputs:out + } + + def Shader "TangentNode" + { + uniform token info:id = "ND_tangent_vector3" + string inputs:space = "world" + float3 outputs:out + } + + def Shader "TangentNormalize" + { + uniform token info:id = "ND_normalize_vector3" + float3 inputs:in.connect = + float3 outputs:out + } + } + } + + # Material with bricks normal map + def Material "NormalMapMaterial_Bricks" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.7, 0.4, 0.3) + float inputs:base_weight = 1.0 + float inputs:base_metalness = 0.0 + float inputs:base_diffuse_roughness = 0.0 + float inputs:specular_weight = 0.5 + float inputs:specular_roughness = 0.6 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.7, 0.4, 0.3) + float inputs:roughness = 0.6 + float inputs:metallic = 0.0 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTexture" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-bricks.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 + } + + def NodeGraph "NodeGraph" + { + float3 outputs:normal_out.connect = + float3 outputs:tangent_out.connect = + + def Shader "TexCoord" + { + uniform token info:id = "ND_texcoord_vector2" + int inputs:index = 0 + float2 outputs:out + } + + def Shader "NormalMapTexture" + { + uniform token info:id = "ND_image_vector3" + asset inputs:file = @./textures/normalmap-bricks.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + float inputs:scale = 1.0 + float3 outputs:out + } + + def Shader "TangentNode" + { + uniform token info:id = "ND_tangent_vector3" + string inputs:space = "world" + float3 outputs:out + } + + def Shader "TangentNormalize" + { + uniform token info:id = "ND_normalize_vector3" + float3 inputs:in.connect = + 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"] + } +} diff --git a/models/mtlx-normalmap-sphere.usda b/models/mtlx-normalmap-sphere.usda new file mode 100644 index 00000000..b0ac99f4 --- /dev/null +++ b/models/mtlx-normalmap-sphere.usda @@ -0,0 +1,142 @@ +#usda 1.0 +( + doc = "MaterialX Normal Map Test - Sphere Geometry" + metersPerUnit = 1 + upAxis = "Y" + defaultPrim = "World" +) + +def Xform "World" +{ + def Sphere "NormalMapSphere" ( + prepend apiSchemas = ["MaterialBindingAPI"] + ) + { + double radius = 1.0 + rel material:binding = + } + + def Scope "_materials" + { + def Material "NormalMapMaterial" ( + prepend apiSchemas = ["MaterialXConfigAPI"] + ) + { + string config:mtlx:version = "1.39" + token outputs:mtlx:surface.connect = + token outputs:surface.connect = + + # OpenPBR Surface Shader with normal map + def Shader "OpenPBRShader" + { + uniform token info:id = "ND_open_pbr_surface_surfaceshader" + color3f inputs:base_color = (0.7, 0.8, 0.9) + 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.25 + float inputs:specular_ior = 1.5 + float3 inputs:geometry_normal.connect = + float3 inputs:geometry_tangent.connect = + token outputs:surface + } + + # Fallback UsdPreviewSurface + def Shader "FallbackShader" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor = (0.7, 0.8, 0.9) + float inputs:roughness = 0.25 + float inputs:metallic = 0.0 + normal3f inputs:normal.connect = + token outputs:surface + } + + def Shader "FallbackNormalTexture" + { + uniform token info:id = "UsdUVTexture" + asset inputs:file = @./textures/normalmap-gradient.png@ ( + colorSpace = "raw" + ) + token inputs:sourceColorSpace = "raw" + float2 inputs:st.connect = + 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 = + float3 outputs:tangent_out.connect = + + # 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-gradient.png@ ( + colorSpace = "raw" + ) + float2 inputs:texcoord.connect = + float3 outputs:out + } + + # Convert tangent space normal to world space + def Shader "NormalMapNode" + { + uniform token info:id = "ND_normalmap_float" + float3 inputs:in.connect = + 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 = + 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"] + } +}