0
1

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.

[テクスチャ] BlenderでColladaファイルをエクスポートすると、UV座標の原点位置が異なって出力される

Posted at

概要

FBXファイルをBlenderを用いてColladaファイルに変換すると、左下を原点としたUV座標で出力されるので、そのまま値を使用すると意図しないマッピングがされてしまう。

他の記事

colladaファイルのテクスチャが上手く貼れない件について、かなり長い時間自分のプログラムを疑って調査をしてしまったが、蓋を開けてみればファイルの変換で原点が異なるという簡単な原因であった。
ググってみると、Blenderで変換するとUV座標の原点位置が左下になってしまうという記事がいくつかあったので、同じ罠に嵌っている方がいれば参考にしてほしいと思う。
https://shikemokuthinking.blogspot.com/2013/08/fbxuv_2.html
https://qiita.com/yukimituki11/items/7dc1ec71df37b38ec3a5

Blender

Blenderのマニュアルを漁っても原点が左下である記載は見当たらなかったが、実際にBlenderでUV editingをみると、たしかに左下が原点だった。
下は不死鳥のモデルのテクスチャの一枚だが、(0, 0)の位置に丸くカーソルが当たっている。
スクリーンショット (20).png

モデルの権利表記

This model was created by NORBERTO-3D
https://sketchfab.com/3d-models/phoenix-bird-844ba0cf144a413ea92c779f18912042

LICENSE Creative Commons Attribution
https://creativecommons.org/licenses/by/4.0/legalcode

対処法

Blender側で原点位置を変えるなどいくつか考えられるが(可能かどうかは不明)、プログラム側での対処としてはV座標を

v = 1.0f - v

で変換する方法も考えられる。
Colladaファイルにはテクスチャ座標は

library_geometry > geometry > mesh > source id = *map*

の場所に保存されるはずなので、sourceからデータを読み取るときにV座標だけ1.0fから引く。
上図の不死鳥のtechnique_commonには

<technique_common>
  <accessor source="#Mesh_001-mesh-map-0-array" count="12189" stride="2">
    <param name="S" type="float"/>
    <param name="T" type="float"/>
  </accessor>
</technique_common>

とあるので、UV座標ではなくST座標といった方が正確かもしれない。

最後に

フォーマットの変換に用いたツール側に原因があったという例なので、同じ現象に嵌って自分のコードを何度見直してもテクスチャが上手く貼れない原因がわからず、絶望している方の助けになれば幸いです。

colladaファイルからデータを読み込んで、Androidでray tracingパイプラインを作成しモデルをレンダリングするサンプルコードをGitHubに上げていますので興味のある方はご覧ください。
https://github.com/kodai731/Aqoole-Engine-Android-Vulkan-Rendering-Engine-

はてなブログにも色々書いています。
https://blog.hatena.ne.jp/Aqoole_Hateena/aqoole-hateena.hatenablog.com/

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?