ざきのメモ

2019/08/22

obj を usdz に変換するメモ

このページには、3Dモデルのファイルフォーマットである obj 形式から、usdz 形式へ変換する方法をメモしています。

環境

  • macOS Mojave
  • Xcode Version 10.3 (usdz_converter Version: 1.009)

方法

そのまま変換

$ xcrun usdz_converter sample.obj sample.usdz

テクスチャを貼って変換

$ xcrun usdz_converter sample.obj sample.usdz -color_map texture.png

テクスチャを貼ったけど、色が暗いなと感じる場合

デフォルトの変換ではメタリック値が高く、色が暗く見えてしまいます。

なので、メタリック値を下げてみましょう。

以下のような真っ黒のテクスチャを作り、それを引数に加えることで、メタリック値を0と指定できます。

$ xcrun usdz_converter cube.obj cube.usdz -color_map texture.png -metallic_map black.png

その他のオプション

以下のようにヘルプオプションをつけてコマンドを実行することで、その他のオプションを確認できます。

$ xcrun usdz_converter -h

以下、抜粋です。

USAGE:
<inFilePath> <outFilePath> [options...]
	Options:
                -g groupName [groupNames ...]       Apply subsequent material properties to the named group(s).
                -m materialName [materialNames ...] Apply subsequent material properties to the named material(s).
                -h                                  Display help.
                -a                                  Generate a .usda intermediate file.  Default is .usdc.
                -l                                  Leave the intermediate .usd file in the source folder.
                -v                                  Verbose output.
                -f                    filePath      Read commands from a file.
                -texCoordSet          set           The name of the texturemap coordinate set to use if multiple exist (no quotes).
                -opacity              o             Floating point value 0.0 ... 1.0
                -color_map            filePath
                -normal_map           filePath
                -emissive_map         filePath
                -metallic_map         filePath
                -roughness_map        filePath
                -ao_map               filePath
                -color_default        r g b a        Floating point values 0.0 ... 1.0
                -normal_default       r g b a
                -emissive_default     r g b a
                -metallic_default     r g b a
                -roughness_default    r g b a
                -ao_default           r g b a

(*) Specify infield only with -v (Verbose) to display group information.
(*) '#' in the first character position of a line in a command file interprets the line as a comment.

参考

Copyright © 2017-2021 Ryo Okazaki, all rights reserved.