More about occlusion (part I)

June 16th, 2009

For example, I have a scene in the image below:

screen shoot of the examplescene

screen shoot of the examplescene

when using the MR shader mib_amb_occlusion node, if we want to render a pass that has the occlusion of the sphere rendered with out display it, normally we can just turn the sphere’s “primary visibility” off. It fits 90% percent of this kind of situations.

However, if user want not only the sphere’s occlusion be rendered, but also none of the boxes generate occlusion, it will be problem because if I turn “primary visibility” of all the boxes off, nohing will be rendered, and if not, the occlusion of sphere on boxes and the occlusion of boxes themselves will be rendered altogether, below is the undesirable result I got if just turnning the “primary visiblitiy” off:

rendered image with spheres pri visibility off

rendered image with sphere's "pri visibility" off

Obviously, the occlusion inbetween the gaps of the boxes are sometimes not we want…

This is when the “ID Inclexcl” “ID Noself” attribute come into handy.
Actually, the djx blog has a really good explain to this:

click here

One important thing to notice is that the “miLabel” attribute is case sensitive.

And for sake of  saving time, I wrote a script for assign the “miLabel” attr to all the selected objects.

Again, since it’s a reall small script, I wrote it with Python in Maya:

Click here

Copy the code into the Python tab of the script editor and use it….

After assign the miLabel to the boxes and sphere, I assign all the boxes’ miLabel =3, and assign the miLabel of the sphere to 1.

Moreover, correspondingly, assign the mib_amb_occlusion shader like this:

assign the ID correctly

assign the ID correctly

Then we will get the desired result:

result of correct ID set up in the shader

result of correct ID set up in the shader

With this set up, we can have only the sphere’s occlusion that affect the evironment…..

A little script to add the light annotations

June 4th, 2009

Inspired by my Friend Al Torres, I wrote a script to add annotations to all the lights in the scene.

Also, if lights’ names have been changed by usrs, re-run the script will update the annotations.

Since it’s very small script, and I don’t want people bother too much to install pymel, I wrote it with default python for Maya script.       This scriptif for usr has a lot of lights in the scene and might have a hard time to remember which light is for what…

Also, name the lights properly before using this script will be a good choice.

create annotations and updated names

annotations added and updated

Here is the script:

ling_addLights_annotation

Copy the codes and run in scripts editor. Hope this will help

Update: The last version of script has some bug: if a light in the scene has more than one children node, the script will not working due to my cheesy approach of finding the annotation node. For example:


Sometimes when duplicating the light an annoying camera node will be created

annoying camrea with the light

Sometimes Maya attaches a camera node to a light when duplicating it, the refined version of the script will delete the camera nodes attached to the light. Also, the script will check each children node of a light, make sure there is an annotation node in it. If yes, just update the light’s name when necessary. If not, create the annotaion.

Here is the refined version: ling_annotation_refine

Go Crazy with Dynamic Hair( Part II)

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


Problems:

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)

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.

Notes:

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

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
else:
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

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.

Ling

Start to Write a Ray tracer

April 23rd, 2009

Inspired by MS. Marilyn Friedman from Dreamworks, I started this afternoon trying to write a ray tracer.

When I was interviewing with Marilyn, she told me that at Dreamworks, the effects challenge program is actually teaching people to write a raytracer.

For me, why not try to write one by myself…
So this is the start.

I installed Visual Studio and MSDN on my laptop this afternoon, and did some researches about the C++ raytracer.

here are some ref links:
ref01
ref02
ref03
ref04
ref05

Now let’s do something

Spring 09, my first website

April 15th, 2009

I finally had my website… Cheers for all the awesome people at Monty..