Archive for May, 2009

Go Crazy with Dynamic Hair( Part II)

Thursday, May 28th, 2009

Since the result for the puffer ball dosen’t look to bad, I wanted to do more with the dynamic hairs. I am taking Independent study with Prof. Bridge Gaynor, so I can free free to do what I want to achieve. The video below is the result. In this project, for the dynamic part I am pretty satisfied. However, for the lighting and intergration part, since I had a lot of trouble with the hair cache(which is famously known as bad), I did not  have much time do make the lighting look good…. I will re-light the scene during the summer.

Anyway, here is the result for right now:

result for right now

BG and Look development:

I shot the BG plate at the Jepson center of Savannah, and I wanted to create a senario that things are a little different than normal. I want to create the CG jelly fishes floating and “swimming” in the air. Beside the jellyfish, I want some CG water coming down the steps. With these two major different CG elements, I need use Maya, MEL, Pymel, Houdini, which makes this project really exiting to me.

Here is the BG shot:

shot with HVX200 and tracked with PFTrack

shot with HVX200 and tracked with PFTrack

I shot the scene with HVX200 camera, tracked it with PFTrack, and created proxy geometry for houdini as collision objects for the water.

Jelly Dynamic:

Attempt 1: In the beginning I planned to create dynamic hair, then use pointOnCurveInfo node to position joints, also add a expression to each joint(force the joint translate with the curve’s certain U value). Then after this, skin the pre-modeled jellyfish geometry with the number of joints….here is a test result:

with joints created, not very efficient way

with joints created, not very efficient way

As people can easily imagine, this approach is very inefficient, too many non-properly used nodes such as expression node, pointOnCurveInfo node have been added into the construction history. And the playback is really slow even just with one jellyfish in the scene.

Attempt 2: Instead of using joints to deform the geometry, simulate the hair curves and then loft a surface based on the curves is much easier and straigt forward. So I deleted the hand modeled geometry, twicked the script to automatically duplicate hair curves, then create a loft based on the hair curves. As a result, as long as the hair curves are dynamic, the surface is moving correspondingly.

here is the result:

lofted surface version is much faster than joints skin version

lofted surface version is much faster than joints skin version

In addition, I changed the curves from 2 skin curves to one skin curve, which will prevent the penetration issue in the later on dynamic simulation stagest(the self collide will help the hair curves reduce the likeness of penetration)

Attempt 3: To get a better control of simulation, make the rest curve pre-animated or pre-defined is better. So I created a blendshape for the rest curve, and when the blend value chage from 0 to 1, the rest curve will change from close position to open position, which represent the open and close motion of the jelly skin.

blendshape animation

Attempt4: After this, I lofted the surface, and based on the surface’s U value, I attached 600 folicles onto the surface, then each folicle has been attached a dynamic hair curve. 600 is pretty decent for the density of small curves on the edge of the skin. All these folicles and hairs are go with a new hair system that gives a seperate hair behavior control.

What’s more,  I added another hair system and some dynamic hairs to represent the long organic skin. Three other surfaces have been lofted based on the motion of the hair curves. Addition to this, a simple cluster and a circle as a controller created as a easy rig. As a result, the controller moves the shape node of the rest curves, causing all the dynamic system to response.

And here is the result:

all hair systems for a jelly created

all hair systems for a jelly created

Attemp 5: For the sake of better control of simulation tweaking, I wrote the UI for the tool:

As user can see, I can set and key random value to the open_close value of the jelly’s skin, which brings the jelly to live. Also, to get individule jelly’s corresponding hair system and cache them, some helper funcion such as “select hair system” and “set start frame” added:

UI to get better control and simulation

UI to get better control and simulation

Final result for the simulation part:

playblast of dynamics


a. The dynamic hair cach system in Maya has been offering a really bad time. I ‘ve tried to customize the hair cache a litlle by constructing my own cache command. However, after this, Maya would never find the correct cache file again. I searched online for a while but no good anwser…. Which make me really unhappy was, since Maya can’t find the right cache, before it go to batch render the frames, it will re-simulate all the systems. This problem has been enlarged 10 times because I set up at least 10 render passes in my maya scene. As a result, even though the local render time was 3-10 second per frame per pass in average, I could not render my sequence within 2 hours per frame on the render farm, In the end, I have batch render locally, which consumed my time should be decicated to the lighting part.

b. another problem is a little weird but I think is fixable:

I wrote all the script in Windows. It works fine and the UI works perfectly. However, when I worked on Linux, the UI dosen’t display correctly. Except all the framelayouts, I lost all the buttons, fieldgrps, and instruction texts… Weird…Will looking into it later.

And the here is the lighting breakdown so far:

lighting breakdown

Special Thanks:
I need to appreciate Prof. Bridget Gaynor and prof. Ken Huff, without their greate suggestions I would finish this with more unnecessary pains.

Go Crazy with Dynamic Hair( Part I)

Thursday, May 28th, 2009

This started from the script I wrote for Mr. Hanwei Wu, he did the lighting part of the puffer ball. He wanted a puffy ball for his TD comp class.

Here is the final result:

result , and lighting done by Hanwei Wu

To do this, I came up with an idea that use dynamic hair system to control the shape node of the  geometry, treat the hair system as the deformer of the tips of puffy ball.

put a folicle on each poly face, then create a dynamic hair based on it

puffer ball algorithm

To actually do this, I figured out how Maya attaches dynamic hair curves onto geometries.

a. create a hair system. Connect certain nodes to it such as Time node.

b. create a folicle node, which act as the bridget of hair system and the hair curves, also, with the help of : folicleShape.outTrans and folicleShape.outRotate, it can xform its transform node, so that the folicle can stick to the geometry.

c. create a rest pose curve, connect it to the hair system also.

d. create a curve as a dynamic hair, connect the hair system to the hair curve.

e. connect the folicle to the hair system and also the hair curves.

the steps above sounds a little confusing, the actual codes from my scripts can be easier to explain the steps:

connectAttr( ‘time1.outTime’, (hairSystemName+’.currentTime’),f =1)

connectAttr(geoShapeName[0] +’.outMesh’, follicleName + ‘.inputMesh’)
connectAttr(geoShapeName[0] +’.worldMatrix[0]‘, follicleName + ‘.inputWorldMatrix’)
connectAttr(follicleName  +’.outRotate’, follocleTrans[0] + ‘.rotate’)
connectAttr(follicleName  +’.outTranslate’, follocleTrans[0] + ‘.translate’)
## connect rest curve
connectAttr( (curveName + ‘.worldSpace[0]‘), (follicleName + ‘.startPosition’),f =1 )
## connect follicle to hair system
connectAttr( (follicleName + ‘.outHair’), (hairSystemName+ ‘.inputHair['+ str(i)+']‘),f =1 )
## connect hair system to follicle
connectAttr( (hairSystemName + ‘.outputHair[' +str(i) +']‘), (follicleName + ‘.currentPosition’) ,f =1)
## connect follicle to hair curve
connectAttr( (follicleName + ‘.outCurve’), (hairCurveName[0] + ‘.create’),f =1 )

notice:  “i” is the the index of curves in an curves array. codes in green color are used in a for loop.

Here is the result:

all nodes created and connected

all nodes created and connected

Then do a extrusion based on dynamic hair and its corresponding poly surface.With this set up, When I move the controller curve,the extruded geometry will act the same as dynamic hair curves.

Then it comes a really big and currently unsolvable problem for me: The extrusion nodes has limitaion:

a.Because my approach needs the “extrude along curve” option of the extrude node, the node need to specify the face to be extruded, and the curve to extrude along with. The problem is, with the “exturde along the curve ” option on,  every extude node only take one face and one curve to extrude with. As a result, each face on the geometry creates a extrude node in the construction history.

b. According to the real puffer ball, I need at least 400 hundred faces extruded, which means 400 extrude node in the history. I tried with this number and it took about 10 minute to open the hypergraph.

Instead, I decide use 96 (which is a box smoothed twice) faces to get the better performance.


Before I know how the folicle node works, I came up a hard way to attach the rest curve to the move geometry.

what I did are :

Create a pointOnSurfaceInfo (or pointOnMeshInfo node in bonus tool), assign a certain UV value (certain poly face index also in the case on pointOnMeshInfo), then get the corresponding (x,y,x) value automatically.

Aassign a expression to the rest curve, which connect the position data of pointInfo node to the tranform node of the curve.

compares to the steps above,  folicles is very handy, given the U and V value of connected mesh/surface, the folicle node can automatically know where the corresponding postion of a UV point on a surface/mesh. With this method I can save two other nodes: pointOnSurfaceInfo and a expression node(when assign an expression, an expression node will be  created) . For the efficiency wise, I am very happy with the folicle rather than the others.

Also, the folicle node can be capable of position object onto the surface, such as do the same thing as the famous “rivot” MEL scripts does, and  it can be used to stick object to either dynamic simulated or keyed surface.

A little script to generate a nautilus

Friday, May 8th, 2009

To help my friend to generate a nautilus shell model, I’ve tried to write a script to model it.

And I found the math referrence here

screenshot of generated model

screenshot of generated model

According to the math, the shape of the nautilus majorly depends on two constant value a and b

and the the corresponding pymel codes are:

r = a*exp(radians(Delta_angle*n)*cot(b))
x = r*cos(radians(Delta_angle*n))
if(n ==0):
y = 0
y = 10*(rBefore -r)
z = r*sin(radians(Delta_angle*n))

Then the rest are just create circle based on the calculated point positions, then do a loft

What’s funny was before I finish this script my friend had already done his model by hand….

At least is was fun though.

And two days after this, Sandro asked me how to write a spiral ST coloration in RSL,

showed him the algorithm in 5 minutes, happy coincidence.

currently editing the blog pages, sorry for the viewing problem

Wednesday, May 6th, 2009

I’m switching the blog theme from the defult to a theme that has my design…. To finish this I have to deal with PHP stuff which is not a enjoyable thing for me right now. But anyway, have something to learn is alwasys good.

Sorry for the mess going on in my blog now, this may last for a little while.