0
2

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 5 years have passed since last update.

Maya python で画像テクスチャをマテリアルに割り当てるメモ

Last updated at Posted at 2019-11-07

背景

Maya でマテリアル設定をスクリプトで処理したい.

手順

Applying a Texture in Python
https://forums.cgsociety.org/t/applying-a-texture-in-python/1573565/7

Assigning a Material using Pymel
https://discourse.techart.online/t/assigning-a-material-using-pymel/1240

maya.cmds を使うと想定

import maya.cmds as mc

File シェーダを作り, テクスチャファイルパスを設定.

shader ノードを作り, テクスチャを割り当てたい shader の attribute(e.g. color) と, file.outColor をつなぐ

シェーダは直接オブジェクト(メッシュ)に割り当てできないようなので, shadingGroup ノード(surface shader や, volume shader などをまとめるノード)を介する.

shadingGroup ノードの .surfaceShader を, file shader の .outColor とつなぐ.

shadingGroup を, オブジェクトに割り当てる. いろいろ方法があるようだが, maya.cmds だと sets が楽か?

mc.sets("geo", edit=True, forceElement="sg1")

構造としては以下のようになる(Maya Node editor で確認したほうがわかりやすいかしらん)

object(mesh) <- shadingGroup node (.surfaceShader) <- (.outColor) File shader (.fileTextureName) <- Texture filename

発展

volume shader や displacement shader として割り当てたい場合は shadingGroup のつなぐ attribute を変えればよい.

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?