Thursday, December 18, 2014

Demoreel update !

Hi folks,

Here is my latest updated demoreel where I show works I have done as Lighting / Comp TD or Pipeline TD, more update to come soon !


Tuesday, November 11, 2014

hman: Jobs management tool (beta version 0.5.0)

Hi all,

I would like to share a python tool I've been working on for several weeks now: hman ( for Houdini MAya Nuke ).




It allows you to create a stack of jobs and run them one after the other. Jobs can be:

- Maya jobs => Rendering a scene or exporting meshes to obj format. You can as well override the camera used or the render layers rendered from hman directly ( .ma file strongly advised ).

- Houdini jobs => Rendering nodes from a given hip file. Nodes supported for the moment are : Mantra nodes, comp nodes and rop output. You can select the node you want to render from hman directly.

- Nuke jobs => Writing images from a given write node ( from a nuke script) , which can be selected from hman too.

- Python jobs => Executing a Python script with a given Python interpreter.

- Batch command jobs => Can either run a .bat file or a given command with args if any ( test on window only for the moment ).


hman main user interface


This tool is written in Python, but doesn't use software python implementation directly as Hython or maya.cmds, it generates scripts and run them with the proper interpreter, this means it can be used with any Python 2.x versions. It's written using PyQt4 tho, be sure you have the right version of PyQt, compatible with the Python version you use, in the "libs" folder.

You can download the source code latest version on Github. Keep in mind it is still in beta version.




Find more infos and documentation here: hman doc

Any questions, feel free to contact me: contact@guillaume-j.com

Sunday, October 5, 2014

PyTake2 create take using python in Houdini

PyTake is now completely rewritten, new version is now fully object oriented. It allows the user to create and edit takes in houdini using python.

It works with all version of Houdini (Apprentice, Apprentice HD, escape, master or Indie.) Free for all usage ( comercial or not ).



To create a new take, just instance a new Take() object :

import PyTake2 as pt

# This will create a new take and add it to the take list
myTake = pt.Take('mytake')

#This will include the display flag of the node « /obj/grid/grid1 » to the take.
myTake.includeDisplayFlag('/obj/grid/grid1')

# You can also use a hou.Node() as parameter :
node = hou.node('/obj/sphere/sphere1')
myTake.includeDisplayFlag(node)

# To include all parms of a node to the take, use :
myTake.includeParms(node)

# To add only some parameters, use :
myTake.includeParms(node, parms_dict={'radx':None, 'rady':None, 'radz':None))

# To add only some parameters, and set node's parameters values use :
# This will set radx to 5, rady to 1 and radz to 2 in the take.
myTake.includeParms(node, parms_dict={'radx':5, 'rady':1, 'radz':2),set_parms_value=True)

#To exclude parms from the take, use :
myTake.includeParms(node, parms_dict={'radx':None, 'rady':None, 'radz':None},include=False)

# To copy a take
copy_take = myTake.copy()
# => this create a new take name_copy

# To remove a take :
myTake.remove()

Sunday, September 21, 2014

Maya / Houdini Python live connection

I'm playing a bit with rpc module and python. Here is a little example of what I've tried so far, a live connection between Maya and Houdini.
Maya looks up for Houdini start up and then connects its python to Houdini's automatically. Thanks to that, in this video, I create a "live connected" camera and I can also send meshes directly from Maya to Houdini ( and vise versa ).

This needs the rpyc module for Python 2.7 ( it is also included with Houdini ), you can downloaded it at this adress : http://rpyc.readthedocs.org/en/latest/

Here is the source code for the connection Maya => Houdini. It must be saved in the scripts folder of maya and used as followed from a Python shelf tool:

        import MayaModule
        ui = MayaModule.MayaConnectionUI()
        ui.show()

You can copy the icons green_light.png and red_light.png in a folder "icons" saved in the same place as the python file.

On the Houdini side, you must have a Python file called "123.py" (or hescape.py if you use Houdini Escape ) withthese two lines of code in it:

        import hrpyc
        server = hrpyc.start_server(port=18812)





Saturday, August 30, 2014

Alien Isolation Trailer

A it late, but finally here is the latest trailer I worked on at Axis animation, as lighintg / compositing artist and TD ! That was almost a year ago... Good to see it online !


Tuesday, August 5, 2014

Powerful method hou.hipFile

Just a quick arcticle to speak a bit about the not well known but powerful python class hou.hipFile.
It allows you to have access, open, edit, save, merge hip file from python. For instance, you could drive Houdini from an external python tool without opening Houdini at all.

You have access then to all python methode of the Houdini module. You can export geos, do mantra rendering, create / manipulate object and otls etc.

For instance the code bellow, we will open the hip file "houhipfile.hip" and export the geo which is in that file tanks to a rop_output node, (warning this does not work with houdini apprentice):

# Here we setup the path to the HIP file as well as where you want to export the bgeo file.
PATH = r"H:/houhipfile.hip"
OUTPUT_GEO = r"H:/teapot.bgeo"

# Here we load the hip file.
hou.hipFile.load(PATH)

# Then we fetch the rop output node
ropNode = hou.node("obj/outputGeo/rop_output")

# We change the Ouput path parameter
ropNode.parm("sopouput").set(OUTPUT_GEO)

# We do the render ( exporting the geo )
ropnode.render()

# And finally we clean the current houdini session
hou.hipFile.clear()

This could be launched from any python tool, with a nice UI in PyQt for instance.

Instead of opening a hip file, you could of course create nodes from scratch:

root = hou.node("/obj")
geo = root.createNode("geo")
and then you have access to the geo node's parms, etc.

More infos here => hou.hipFile class help
And you can download the hip file as example here

Tuesday, May 6, 2014

Tutorial: Python sop in houdini [ENG/FR]


French Follows!


The idea of this article is to show how to use Python in Houdini for the creation of SOP node. In order to follow this short tutorial you should know basic of Python as well as Houdini ( SOP nodes, digital assets création ... ).

You can find a ready to go otl Here, and you can download the python source code Here.

We're going to create an otl via Python which will be able to return in a point attribute the value of the angle between each edges of a ordered curve.
I insiste on that point, the curve must be ordered ! that means points order must follow the direction of the curve. To order curve's points you have multiple possibilities like sort node, nurbs UV, pathfinding etc. This might be the subject of another article later on.
This tool could be created throught vex or with normal nodes of houdini, but the point of this tutorial is to show how python works in Houdini :)

There are multiple ways to use Python in Houdini, here, we'll create a SOP node by Python.
First, we'll create that node, which is actually nothing else than a digital asset. Use the menu "File => new operator type", then select type: "Python" and "Geometry node" ( it means "SOP node" actually ).
Don't forget to put a name an label just like an normal digital asset.
A window similar to digital asset création opens, the difference is that the tab "Code" is available. This is where we will write our code.
You can see that Houdini write for us a bit of starting code :)

# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()

# Add code to modify the contents of geo.

Houdini write what is needed in order to fetch the geometry and the node you need.


node = hou.pwd() => creates a reference to the current node ( our otl )
geo = node.geometry() => creates a reference of the geometry of the current node, this is where you can modify the actual geometru ( points, vertex, prim etc. ).

We will create also 2 parameters:
One float called "threshold" with a range from 0 to 180 and a default value at 120.
One String called "groupname", with a default value "anglegroup".



You can download the source code here, we'll have a look on that line after line:

First of all, we import all the python modules needed. You can import you custom modules as well, as long as they are saved in a folder scanned by Houdini.
import math
import numpy

As seen, we create here a reference to the current node, as well as the current geometry
The line "points = geo.points()" returns a list of all points in the current geometry.
node = hou.pwd()
geo = node.geometry()
points = geo.points()

Here we save in a variable "_threshold" the value of the parameter "threshold" exposed in our UI.
_threshold = node.evalParm("threshold")

Then we create a point group, empty for the moment and which will have the name found in the parameter "groupname".
grp = geo.createPointGroup( node.evalParm("groupname"))

We create an attribute type point which will have as name "angle" and as default value -1.0. This will allow us to save, for each points, the value of the angle found. For points which won't have angle values the attribute value will be -1.0. ( We will see later on that it's in fact, extremities of the curve)
attr = geo.addAttrib(hou.attribType.Point, "angle", -1.0)

It's here that we start to compute the angle value for each edges. We have to compute the angle between each vector 0 => 1, 2 => 1, 1 => 2, 3 => 2 etc...




Let's do a bit of math ! We have 3 points p0, p1, p2, the vector v0->1 will be compute as followed:

vx = p0x - p1x
vy = p0y - p1y
vz = p0z - p1z

Where p0x is the position.x of the point 0 etc.

For each points of the curve, we will use the current point ( i ) and also the point before ( i-1 ) and the point after ( i+1 ) on the curve.
So we will start the loop at 1 in order to skip the first point ( which is the point[0] ) and ends it at (length of the list -1) in order to skip the last point:
for i in range(1, len(points)-1):

Here we save in variables these 3 points.

    p1 = points[i-1]
    p0 = points[i]
    p2 = points[i+1]
    
Using the method Hou.Point.attribValue(name) we can access to the position values of each points. As the attribute is a vector(x,y,z) we can fetch each values separately for each points:

    p0x = p0.attribValue("P")[0]
    p0y = p0.attribValue("P")[1]
    p0z = p0.attribValue("P")[2]   

    p1x = p1.attribValue("P")[0]
    p1y = p1.attribValue("P")[1]
    p1z = p1.attribValue("P")[2]

    p2x = p2.attribValue("P")[0]
    p2y = p2.attribValue("P")[1]
    p2z = p2.attribValue("P")[2]
    
Then we calculate the vector coordinates and put them in a numpy.array()
    v1 = numpy.array([p0x - p1x, p0y - p1y, p0z - p1z])
    v2 = numpy.array([p0x - p2x, p0y - p2y, p0z - p2z])
    
Some more math ! The angle between 2 vector in radian is found by:
    acos( dot(normalize(v1), normalize(v2)))

In our case the line "v1 = v1/numpy.linalg.norm(v1)" normalize our vector v1.
and "numpy.dot(v1, v2)" returns the dot product of there 2 vectors.
then, "Math.acos(x)" will return the angle in radian where x is the dot product result.
finally math.degrees(x) will convert radian value to degres angle value.

    out = math.acos(numpy.dot(v1/numpy.linalg.norm(v1), v2/numpy.linalg.norm(v2)))
    out = math.degrees(out)
    
We save the angle value in the point attribute we created:
    points[i].setAttribValue(attr, out)

And as bonus, if the angle found is smaller than the threshold value, we put the current point in the point group we created.
    if out < _threshold:
        grp.add(points[i])

Et voilà ! Our node is ready to be used ! We could've add some other options like change the threshold test via an option "greater than or smaller than", expose a string parameter for the name of the attribut angle etc.

The node is in the tab menu at SOP level only, ready to go :)

Any questions or comments: contact@guillaume-j.com !


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------



L'idée de ce billet est de présenter un peu l'utilisation de Python dans houdini au niveau SOP object. Ce court tutorial part du principe que vous connaissez déjà les rudiments de Python ainsi qu'Houdini (Nodes SOP, création de digital assets etc.).

Vous pouvez trouver ici un digital asset pré-fait, ainsi que le code source python ici.

Nous allons créer un otl en python qui sera capable de retourner dans un point attribute la valeur de l'angle observé entre chaques edges d'une courbe ordonnée.
J’insiste sur ce point: la courbe doit être ordonnée, c'est a dire que les points de la courbe suivent le sens de la courbe elle-même. Pour ordonner une courbe de points qui aurait des points générés de façon aléatoire, plusieur solutions s'offrent à avous: sort node via attribut, nurbs UV, path finder etc. Ceci fera peu être l'objet d'un autre billet sur ce blog.
Cet outil pourrait être créé avec des nodes "normaux" d'houdini et / ou du vex sans aucuns doutes. Mais l'idée de ce billet est bien de voir comment fonctionne Python dans Houdini :)

Il existe plusieurs façons d'utiliser Python dans Houdini, nous allons voir comment créer ici un SOP node custom en python.
Tout d'abord, créer ce fameux node qui sera en faite un digital asset (otl), par le billet du menu File => new operator type.
Selectionnez le type "Python", et également le type "Geometry node" qui correspond au niveau SOP.
N'oubliez pas de mettre un label et un nom comme un digital asset normal et sauver le.
Une fenêtre comparable à la fenêtre de création de digital assez s'ouvre, la différence est que le tab "Code" est disponible, c'est ici qu'on va pouvoir écrire le code Python.
Vous pouvez d'ailleurs voir qu'on code par défaut a été écrit:

# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()

# Add code to modify the contents of geo.

En effet, Houdini écrit pour nous les bases nécessaires à la création de notre node:



node = hou.pwd()  => créer une référence au node courant ( notre otl ).
geo = node.geometry()  => créer une référence à la géometry courante, c'est ici que sont fait toutes les manipulation sur la géometrie de notre input, au niveau vertex, points, primitives etc.

Nous allons également créer un paramètre "threshold" en float avec un range de 0 à  180, qui nous sera utile par la suite.
Créez également un paramètre string "groupname" avec en valeur par défault "anglegroup".




Vous pouvez télécharger le code source du node ici. Nous allons détaillé ce code ligne par ligne:

Tout d'abord on importe les modules nécessaires, math et numpy. Vous pouvez ici importer toutes sortes de module, interne à Pyhton ou écrites par vous même si elles sont placées dans un dossier scanné par houdini.
import math
import numpy

Comme vu plus haut, on créer des références au node courrant ainsi qu'à la géométrie courante.
La ligne "points = geo.points()" retourne une liste contenant tout les points de la géométrie.
node = hou.pwd()
geo = node.geometry()
points = geo.points()

Ici nous allons enregistrer dans une variable "_threshold" la valeur de notre paramètre threshold qui sera exposé dans l'interface de notre otl.
_threshold = node.evalParm("threshold")

Nous créer ensuite un group de points ( pour le moment vide ), et qui aura comme nom la valeur de notre paramètre "groupname"
grp = geo.createPointGroup( node.evalParm("groupname"))

A cette ligne nous créons un attribute de type point qui aura pour nom "angle" et comme valeur par défaut -1.0. Cela nous permettra de sauvegarder, pour chaque points, la valeur d'angle que l'ont va trouver dans cet attribute. Pour les points qui n'auront pas de valeur d'angle, l'angle restera à -1. ( Nous verrons plus loin qu'il s'agit en faite des extrémités de la courbe.
attr = geo.addAttrib(hou.attribType.Point, "angle", -1.0)

C'est ici que l'ont commence à calculer l'angle pour chaque edge. Il s'agit de calculer l'angle entre les vecteurs entre les points 0 et 1 et 2 et 1, 1 et 2 et 3 et 2 etc...



Un peu de math ! Nous avons 3 points p0, p1, p2, le vecteur v0->1 sera calculé de la sorte:

vx = p0x - p1x
vy = p0y - p1y
vz = p0z - p1z

Ou p0x est la position en x du point 0 etc...

Pour chaque point de la courbe nous allons traiter le point courant ( i ), mais également le point d'avant ( i-1 ) et le point d'après ( i+1 ) sur la courbe. Nous allons donc faire commencer la boucle à 1 pour ignorer le premier point ( qui aura donc une valeur par défaut d'angle de -1.0) et la finir à la longeur de la liste - 1 pour ignorer également le dernier point de la courbe.
for i in range(1, len(points)-1):
    
Ici nous mettons dans des variables px les points correspondants.
    p1 = points[i-1]
    p0 = points[i]
    p2 = points[i+1]
    
Grâce à la méthode Hou.Point.attribValue(name) nous pouvons accéder aux valeur de position de chaque points, comme l'attribut en question est de type vector(x,y,z) nous pouvons récupérer les valeurs d'x, y et   z séparéments pour chacun des trois points:

    p0x = p0.attribValue("P")[0]
    p0y = p0.attribValue("P")[1]
    p0z = p0.attribValue("P")[2]   

    p1x = p1.attribValue("P")[0]
    p1y = p1.attribValue("P")[1]
    p1z = p1.attribValue("P")[2]

    p2x = p2.attribValue("P")[0]
    p2y = p2.attribValue("P")[1]
    p2z = p2.attribValue("P")[2]
    
Nous calculons ensuite les coordonnées des vecteurs qui nous intéressent et les mettons dans une variable   numpy.array().
    v1 = numpy.array([p0x - p1x, p0y - p1y, p0z - p1z])
    v2 = numpy.array([p0x - p2x, p0y - p2y, p0z - p2z])
    
Encore des math ! L'angle en radian entre deux vecteurs est calculé comme ceci:
    acos( dot(normalize(v1), normalize(v2)))

Dans notre cas la ligne "v1 = v1/numpy.linalg.norm(v1)" normalise notre vecteur v1.
Puisqu'on utilise le module numpy, numpy.dot(v1, v2) retournera le dot product nécessaire.
Math.acos(x) retournera la valeur en radian en partant d'un valeur x ( généré par notre dot product             précédent )
Pour finir, math.degrees(x) convertie une valeur x en radian en une valeur d'angle en degrés.
    out = math.acos(numpy.dot(v1/numpy.linalg.norm(v1), v2/numpy.linalg.norm(v2)))
    out = math.degrees(out)
    
    Nous enregistrons la valeur trouvée d'angle dans l'attribut "angle" créé précédemment.
    points[i].setAttribValue(attr, out)

Et en bonus, si l'angle trouvé est inférieur à l'angle indiqué dans le paramètre threshold, nous ajoutons le point courant dans le group créer au début du node.
    if out < _threshold:
        grp.add(points[i])

Et voilà notre node est prêt à être utilisé ! Nous aurions pu ajouter d'autres options comme changer le test du treshold via un paramètre ( greater than, or smaller than ), un paramètre exposé pour le nom de l'attribut angle etc.

Votre node se trouve maintenant dans le menu tab si vous êtes en SOP level ! :)

Des questions ou remarques: contact@guillaume-j.com !

Wednesday, April 9, 2014

Houdini OTLcheck python script

Here is a simple python script for Houdini, OTLCheck

This script allows the user to check which sub-otl(s) are used inside a selected otl.
It checks all sur subchildren nodes and will print a list of otls and path in the console or in the python shell.

If the otl uses a uncomplete asset definition the script will output a warning:
WARNING: node <node path>, is embedded.

The script skips all otls lib built-in shipped with Houdini.

Saturday, March 8, 2014

Houdini Engine test with Unity

Here is a work in progress tool in order to test the Houdini Engine with Unity.

This tool helps the user to create different and procedural kind of "labyrinth-type" level designs in Unity by using Houdini Digital asset ( .otl ).

Features:
  • Create 3 type of labyrinth models with Straight modules ( full instancied models), Vegetal, or "random direction vegetal".
  • Extra path inputs as houdini curves directly in Unity.
  • Project Vegetal and "Random direction vegetal" model on custom terrain mesh.
  • Create a player starting point randomly in the labyrinth.
  • Override every models used as instance to built a new labyrinth model ( Labyrinth modules or trees models for Vegetal type ).
  • Density, radius, etc. Options for vegetal labyrinth.

Video example:



Thursday, February 20, 2014

GJ round decimal

Just finished a small utility node, GJ round decimal which allows the user to round a float value, you can keep from 0 decimal ( convert to int ), to 4 decimals.







Saturday, February 15, 2014

WallGen (Voronoï) updated

I have just updated the wallgen tool, with 3 new feature: Density noise, holes parameters and erode top options. More info here.



It has been also tested in Maya with the Houdini Engine ( more info here ), with houdini installed ( apprentice version works fine ) you can now use the asset ( .otl ) inside maya directly :


Saturday, February 8, 2014

Houdini OTL: Layered Texture

Here is a new little asset, still work in progress, Layered Texture.
Allows the user to create a texture map made of multiple layers inside a material.




Parameters:

- 1 Main layer called "base map", UVs built switch with transforms for main layer

- Layers:

Layer 0 on top of main layer ( generated by default )

Add / remove / clear layers button to add layers.

Enable / Disable layer checkbox
Mode: Multiply, Substract, Mix and Add
UVs transformation for each layers

Layers are comped on top of each other: L2 on L1 (...) on L0 on MAIN.


Python source code available here