Python - HOMで行く! [効率化編]

久しぶりの投稿です。何を書こうかと考えてたら、そういえばPython for HoudiniであるHOM(Houdini Object Model)に関して何も残してなかったので、それをやろうと。






sel_node = hou.selectedNodes()

for n in sel_node:



HoudiniでSIMをレンダリングする時、特にレンダーファームに投げてファーム側でレンダリングする時はIFDファイルを作成しなければならないのだけれども、正直にやってしまうとそのIFDファイルにSIM情報も書いてしまって激重なファイル容量になってしまったり…。それを避ける為に使用するのが、Delayed Load Procedual VEX(Maya、3ds Maxとかで言う、Render Proxy的なもの)を作成する事。だけれども、これをまた作業毎にDelayed Loadとそれ用のオブジェクトコンテナ(OBJ Net)を作成するのが面倒だったり。
なので、それらをDelayed Loadで使用するため、事前に作成したBGEOキャッシュディレクトリを入力しつつ作成するというもの。

sel_cache = hou.ui.selectFile(title="Select BGEO cache")

crDlp = hou.node("/shop").createNode("vm_geo_file")
crDlp.setParms({"file": sel_cache})
dlp_path = crDlp.path()

crGeo = hou.node("/obj").createNode("geo", node_name="geo_dlp1")
crGeo.setParms({"shop_geometrypath": dlp_path})
fileobj = crGeo.node("file1")

Python Scripting with the Houdini Object Model


Scattering inside of geometry

I was wondering why often is Iso Offset used for scattering.

So this post was noted for the notice.

Usually when we make up with Voronoi Fracture or something like Metaball SOP, we use Scatter SOP. In the case of using only Scatter SOP, it provides scattered points only along surface. So It would be useless for a little precise and controlled devision with Voronoi Fracture or something.

Therefore we use Iso Offset SOP when plug between a geometry and Scatter SOP.

P.S. 2013/10/26

There's another way to solve this system: to use Points from Volume.

It has a bit different way of approaching to making distance between points unlike Scatter SOP. This SOP uses Point Separation as FLIP Object DOP.


Transfer colour attributes of textures to points

It's just a easy way though, I actually wondered at this: How can I transfer colour attributes from textures to Points.

Yesterday I was taught a solution for it on Twitter. So I will note this.

Just prepare this network first.

Then lay down Point SOP and connect under Points form Volume SOP.
Add colour attribute to it then type expression into red channel parameter box :
tex( "$HIP/images/legoman.jpg", $BBX, $BBY, R )

and also blue, green channel:

tex( "$HIP/images/legoman.jpg", $BBX, $BBY, B )
tex( "$HIP/images/legoman.jpg", $BBX, $BBY, G )

This means tex ( filename or url, u, v, colour type )

If you decrease Point Separation in Points from Volume SOP, you will get more detailed image like this.

P.S. 2013/01/25

We can also apply image colours to points by using Point Map SOP.

Set up Image Map parameter in Point Map, then it will be done.

tex expression function : http://www.sidefx.com/docs/houdini12.1/expressions/tex
The Visible Lego Man | Badass Digest : http://badassdigest.com/2011/11/16/the-visible-lego-man/


Node: Crease SOP

When making a model divide as keeping the edges details, usually just adding subdivision causes too smooth edges.

In Houdini, we can avoid this problem by using Crease SOP.

Just cut the SOP in queue between under a geometry flow and Subdivide SOP.

Crease SOP