No More Retake

3DCG屋さん向けTips&Referenceサイト

メニュー

Houdini:Pre/Post Render ScriptとSwitch(SOP)

Houdini回。

Mantra(ROP)とかArnold(ROP)とかにある、Pre-Render Scriptと”Switch”を組み合わせた活用例。
作業時は軽いモデルで、レンダリング時やキャッシュ作成時は本番モデルでといった感じにSwitchノードで切り換えます。

最近、仕事でちょっと話題に上がったので取り上げました。

テストで次のようなシーンファイルを用意しました。

シーンにはGeomtryがひとつ。中身はテストジオメトリがふたつ、Switch(SOP)につながっているだけです。また、レンダリング用に、mantra(ROP)がひとつあります。このmantra(ROP)を用いて、Switchを切り替えます。

Mantra(ROP)等のパラメータScriptタブにあるPre-Render ScriptでSwitch(SOP)をコントロールします。
Pre-Render Scriptはレンダリング前に実行されるスクリプトです。ここにSwitch(SOP)を切り替えるPythonを記述します。

パラメータの右側にある言語指定を”Python”に変更しておきます。
複数行のスクリプトを書く場合は、パラメータを右クリックしてメニューから”Expression”->”Edit String”を選んで、エディタを使うと良いです。

ここでは、パラメータ”Pre-Render Script”に次のように記述しました。

import hou
oNode = hou.node("/obj/geo1/switch1")
oNode.parm("input").set(1)

これで、レンダリング前に/obj/geo1/switch1のswitchが切り替わります。

レンダリングを実行することで確認できます。

レンダリングが終わったら、Switch(SOP)を元に戻したいので、パラメータ”Post-Render Script”を使って操作します。
パラメータ”Post-Render Script”はレンダリングがすべて終わった時に実行されるスクリプトです。

言語をPythonに変更し、パラメータ”Post-Render Script”に次のように記述しました。

import hou
oNode = hou.node("/obj/geo1/switch1")
oNode.parm("input").set(0)

これで、レンダリング後にswitchが元に戻ります。

Nukeの$guiみたいなことをやってるわけです。

処理の重いシーンを編集する時なんかに、よく使います。
作業は軽いシーンでキャッシュ取るときに切り替える、みたいな。
でもpython書くのが面倒なので、使わずに重いまま作業したりもします。ずぼらです。

”Nukeの$guiみたいに簡単に設定できたらいいのに”、と思います。

SideFXに要望だしてみようかな。

サンプルファイルはこちらSwitchPython01.hiplc

以上!

関連記事

  1. 2018.04.09

    Houdiniの本!!
  2. 2020.08.02

    Houdini:Coast
  3. 2018.08.18

    Houdini:Spare Input
  1. 匿名 2020.02.26 8:49am

    hou.isUIAvailable() ではどうでしょうか??

    • 0
    • 0
    • kitagawa 2020.02.26 11:27am

      教えていただきありがとうございます。こういう関数があったのですね。知りませんでした。ちょっと使ってみます。

      • 0
      • 0

このサイトについて

3DCG Tipsサイト。Houdiniの記事が多めです。

RSS

follow us in feedly

Archives

  • 2024 (1)
  • 2023 (2)
  • 2022 (9)
  • 2021 (14)
  • 2020 (46)
  • 2019 (17)
  • 2018 (33)
  • 2017 (29)
  • 2016 (36)
  • 2015 (64)
  • 2014 (54)
  • 2013 (60)
  • 2012 (55)

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

Houdiniを使えるようになる本


Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.facebook.com/restserver.php?method=links.getStats&urls=http%3A%2F%2Fnomoreretake.net%2F2020%2F02%2F25%2Fhoudinipre-post-render-script-switch%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http%3A%2F%2Fnomoreretake.net%2F2020%2F02%2F25%2Fhoudinipre-post-render-script-switch%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132