Sunday, February 14, 2016

VDB Research

While I've been studying Houdini has evovled is a constant challenge with CG and tech in general to stay up to date. VDB's or 'openVDB' seems to have been born and matured and come into Houdini.

online docs

Technical Paper by Ken Museth

'VDB' is a open-source hierarchical data structure (and a suite of tools) developed by Dreamworks to handle high quality volumetric rendering (as seen in The Croods, Puss in Boots, How to Train your Dragon 2).

current version (Oct 2015) 3.1.0

Due to the data structure VDB enables constant time O(1) random access to voxels.

VDB allows almost realtime boolean operations

I tried this:
convert from polygons to VDB with "VDB from polygons SOP"
I merged a sphere with a torus, (VDB Combine) then converted back to polygon soup

this work flow allows us to boolean polygons in a new way to the old cookie SOP
which had its own inherent issues, but of course the accuracy of the result is dependent
on voxel resolution. Combining voxels has been previously (a while ago now )
described as a revolutionary way of modeling that was previously restricted by polygon limits.

You can merge different resolution VDB primitives together and the result can be either the lower resolution or the higher.

Houdini's cloud tools make use of VDB data structures.

Python in Houdini - some quick research

python notes

intro to python in H11 (Waqas A.M. Siddiqui)

#when should we use python ?...when you cant do it in Houdini with HScript or nodes

# comments prefixed with a hash (#)  can be appended to the end of a line of code)
2+2 # use python like a calculator
will return 4

#baby steps : drag a node into the python interpreter/window
>>> hou.node('/obj/geo1')
(shelf tools and pane TABS can also be dragged into Houdini)

'dotting in'
>>> n = hou.node('/obj/geo1') # assigning to 'n'
>>> n. gives us the operators for n

>>> n will give us the strign representation of the node (type geo and the path)

# assign the object a variable to work with it
>>> # call its name

# Children at SOP level

# Looping through the children and print the name

# parms

# check out the HOM (Houdini Object Model) section of the Houdini help files
ie HOM cookbook and tips and  tricks

# Build a function
wrap up a snipped of code so we can call it on a whim

# note this recursive (the definition of recursion is recursion)
def childrenOfNode(node):
        result = [] # a list in python
        for c in node.children():
          result append (c)
          result += childrenOfNode(c) # this is where the recursion happens - we are calling the very function               # we have defined
return result

# recall indentation is key in python
# saving to a sessional window allows custom functions to be called with the hou.session prefix

# add your code to the shelf as a shelf tool
right click somewhere on the shelf - choose new tool
in the scripting window - add your python code ie

print 'hello world'

#CTRL-TAB will do your auto-complete for you

# set the pos of a node in a Network editor pane
n = hou.node('/obj/box1')
n.setPosition([.5, .5])

# to see more look in HFS/scripts/python

# adding python into object parameters
ie in HScript - $F/10

in python: (be sure that Houdini knows it is a python expression
and not HScript - Right Click - change expression language to python)

the parm window changes to pink to show the language is not the default language
if the defualt is set to Python then the HScript expression would be in pink

note in parm windows - the hou prefix can be dropped

time() = $T
lvar("PT") = $PT

ie point SOP
lvar("TX") is equivalent to $TX

pwd().curPoint().position() is equivalent to

ALT-E gives us a little editor to help write our python
in this context - if there is more than one line the code is treated as a function
(with breaks shown in the parm window)

point = pwd().curPoint()
if point.number() ==0;
      return 2
return point.position()

kwargs - used through-out houdini
describes a bunch of variables associated with the shelf tool
ie whehere or not you have ALT-clicked the tool or SHIFT-clicked the tool etc
whether or not he tool was invoked from the viewport or not

use sys.exit() to exit from a python shelf tool

shelf tools can be bound to Hot Keys - and they can be invisible form the shelves or viewport pane

in a font SOP (as a python expression):
"Frame $F %s" % int(frame())

will give you the frame number evaluated from the python expression

"%02d:%03d, 1f" % (time()/60, time() % 60)

with string parameters - add a keyframe - then change to python to edit it
you cant add a python expression as a string expression until you have a true keyframe

hou.expressionGlobals()['foo'] = foo
now foo can be called from a python expression
so if you have a lib of your own expressions
you can inject them in to expressions

make a timecode HDA's
make it a HDA - Shift-C
from the subnet create a DA
'ch' can be used just as we would in HScript

use CTRL-g to jump to a specific line in a python scripting window

code in an asset is more global - it lives with the asset
python in a shelf tool may only live on a specific desktop and python in a session may only live in that

Boolean operators ordered by ascending priority:
x or yif x is false, then y, else x(1)
x and yif x is false, then x, else y(2)
not xif x is false, then True, else False(3)
  1. This is a short-circuit operator, so it only evaluates the second argument if the first one is False.
  2. This is a short-circuit operator, so it only evaluates the second argument if the first one is True.
  3. not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.

it has been said that unambiguous code is good, so I imagine writing 'not (a==b)' is preferable to 'not a == b'

use of <> is obsolete but backward compatible to the standard !=

Follow by Email