0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

USD のマテリアル/シェーダ解釈のメモ

Last updated at Posted at 2022-04-23

Blender 3.1 で export されたネットワークを仮定します.

def Xform "Cube"
{
    matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (-1.1853550672531128, 0, 1.9550952911376953, 1) )
    uniform token[] xformOpOrder = ["xformOp:transform"]

    def Mesh "Cube"
    {
        uniform bool doubleSided = 1
        int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
        int[] faceVertexIndices = [0, 4, 6, 2, 3, 2, 6, 7, 7, 6, 4, 5, 5, 1, 3, 7, 1, 0, 2, 3, 5, 4, 0, 1]
        rel material:binding = </_materials/Material>
        normal3f[] normals = [(0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (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, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] (
            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:UVMap = [(0.625, 0.5), (0.875, 0.5), (0.875, 0.75), (0.625, 0.75), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.125, 0.5), (0.375, 0.5), (0.375, 0.75), (0.125, 0.75), (0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (0.375, 0.25), (0.625, 0.25), (0.625, 0.5), (0.375, 0.5)] (
            interpolation = "faceVarying"
        )
        uniform token subdivisionScheme = "none"
    }
}

def "_materials"
{
    def Material "Material"
    {
        token outputs:surface.connect = </_materials/Material/preview/Principled_BSDF.outputs:surface>

        def Scope "preview"
        {
            def Shader "Principled_BSDF"
            {
                uniform token info:id = "UsdPreviewSurface"
                float inputs:clearcoat = 0
                float inputs:clearcoatRoughness = 0.03
                float3 inputs:diffuseColor.connect = </_materials/Material/preview/Image_Texture.outputs:rgb>
                float inputs:ior = 1.45
                float inputs:metallic = 0
                float inputs:opacity = 1
                float inputs:roughness = 0.4
                float inputs:specular = 0.5
                token outputs:surface
            }

            def Shader "Image_Texture"
            {
                uniform token info:id = "UsdUVTexture"
                asset inputs:file = @.\textures\checkerboard.png@
                token inputs:sourceColorSpace = "sRGB"
                float2 inputs:st.connect = </_materials/Material/preview/uvmap.outputs:result>
                float3 outputs:rgb
            }

            def Shader "uvmap"
            {
                uniform token info:id = "UsdPrimvarReader_float2"
                token inputs:varname = "UVMap"
                float2 outputs:result
            }
        }
    }
}

GeomMesh から

materialBinding でどのマテリアルを使うかを調べます.

Material

基本は Shader のコンテナとの理解

シェーダの toplevel? を outputs:surface で指定.

Texture UV coordinates

UsdUvTexture では inputs.st に PrimvarReader をつなぐ.

ちょっとややこしいが, 実際の UV 座標データは, UsdPrimvarReader_float2 ノードの inputs:varname を見て GeomMesh 側の primvars:${varname} を見るようにする.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?