Thursday, 4 May 2017

Random Colour for Houdini Crowd Agents

I am working on a stadium shot using Houdini.

I have found a way of assigning random colors for the crowd agents.

1. Create a shader for your agents, called variation.

2. Create an attribute either on the points from which your agents are generated or on the crowd_sim_import node, which is the node that reads back the simulated agents.

3. Create a stylesheet override, so that your agents pick up the variation shader.

4. In the variation shader, create an Inline Code node.

The inline code node creates the link between the packed primitive and the shader. The renderer looks-up the attribute and passes the attribute value into a new variable inside the shader. You can then use that variable to alter the look of the shader. In my case I just used a rand node to apply a random colour and piped that straight into the shader output without any lighting.

Wednesday, 1 March 2017

Distort and Undistort with PFTrack and Nuke

Here is a reliable way to produce STmaps from PFTrack for use in Nuke when undistorting and re-distorting a plate.

This is the method outlined by Dan Newlands on his excellent blog Visual Barn. There you can find many tutorials and methods for professional Matchmoving.

Dan Newlands walks you through the whole process very clearly and I cannot really add anything much to what he shows you. I want to show my setup in PFTrack and Nuke for my own reference.

Here I show the Add Distortion node. Use the 'original clip size' option. The three export nodes are for the undistorted plate (for use in your 3D app), the undistortion STmap and the re-distortion STmap.
The undistorted plate and the undistortion STmap will have a different size to the original plate, but the re-distortion STmap will have the same resolution as the original plate.

Here is the Nuke setup. The first STmap node will undistort the plate. The second STmap node will re-distort the plate to the original state.
Any 3D rendered elements can be introduced between these two nodes and they will be re-distorted to match the original plate. If that is your workflow, then use the undistorted plate exported form PFTrack in your 3D package and match your 3D elements against that.

One thing to note: if you see blocky or tearing artifacts in Nuke it may be that the filtering option in the STmap node is set incorrectly. I have found that 'cubic' filtering seems to work well, although resulting in some softness in the final redistorted image.

Thursday, 8 December 2016

2017 Show Reels

I am delighted to post my new show reels for 2017.

Here is my Houdini and Maya FX reel, which shows many disciplines including Houdini crowds, Maya nCloth, nParticles, nHair, and fluids. Rendering is done either in Mental Ray or Arnold, and camera tracking is done with either 3DEqualizer or PFTrack.

Here is my Matchmoving reel, which shows some of the most difficult shots I have tackled. All work shown in these shots was done using PFTrack. I am also familiar with 3DEqualizer and Nuke's built in tracker

Thursday, 8 September 2016

Align Particle Instances to a Camera

Here I will demonstrate a method of aligning a particle to face a location (eg a camera), which mimics the behaviour of particle sprites.

This is quite easy to do. First get the position of each particle, then get the position of the location you want the particles to point to. From this you can calculate the aim direction thus:

aimPP = targetPosition - position

To get this done in Maya, follow these steps:

1.    On your particle object, create a new per-particle vector attributes, called aimPP.

2.    Create an expression on the particle:

float $targetX = targetLocation.translateX;
float $targetY = targetLocation.translateY;
float $targetZ = targetLocation.translateZ;

vector $targetPosition = <<$targetX, $targetY, $targetZ>>;

aimPP = $targetPosition - position;

spriteTwistPP = rand(-0.25, 0.25);

float $targetX = targetLocation.translateX;
float $targetY = targetLocation.translateY;
float $targetZ = targetLocation.translateZ;
vector $targetPosition = <<$targetX, $targetY, $targetZ>>;

aimPP = $targetPosition - position;

aimUpAxisPP = << 0, sin(frame*spriteTwistPP), cos(frame*spriteTwistPP) >>;

Now, I was expecting

vector $targetPosition = targetLocation.translate;

to work, but for some reason I cannot think of, it does not work, so I have taken each of the components and constructed the vector from those. Not very elegant but it does the job. If anyone knows why the vector cannot be  assigned, please do let me know!

3.    On the particle shape, set the Aim Direction in the Instancer (Geometry Replacement) section to the aimPP attribute.

If you want the particle instances to rotate as well as face the camera, I am using the spriteTwistPP attribute and then create a new per particle vector attribute called aimUpAxisPP.

Create a random value for spriteTwistPP in the creation expression, then in the runtime before dynamics expression, add the line

aimUpAxisPP = << 0, sin(frame*spriteTwistPP), cos(frame*spriteTwistPP) >>;

Now, for the Aim Up Axis in the Instancer options, choose aimUpAxisPP

Now you can instance any geometry to the particle object and the instances will behave like sprite particles. You can render them with Arnold, too!

Tuesday, 6 September 2016

Maya Sprites with Arnold

I am doing some testing of Maya Sprite rendered with Arnold.

Here is a test scene:


At the moment the setup is not working. I get the same sprite image (number 1) on all the sprites, and the sprites are all oriented the same. I think the problem is that the spriteTwistPP and spriteNumPP attributes are not being passed to the renderer.

After contacting Solid Angle support, it seems that this workflow is not currently supported, but their developers are 'looking at it', which probably means that they will fix it quite quickly.

I will update this post when I have more information.

Wednesday, 2 December 2015

Arnold aiMotionVector with transparency

I will show one method of rendering motion vectors for an object which has transparency.

Here is the scenario:

I have some snowflakes which are comprised of simple polygon meshes instanced to some particles.
I have a circular ramp with noise to give the snowflakes a feathered edge.

What I want to achieve is to render the beauty in one pass and then a motion vectors pass. The motion vectors must have the same opacity as in the the beauty pass.

Here is the trick: In the ramp which controls the opacity, replace the white colour with an aiMotionVector node.

Set the output to Raw in the aiMotionVector node.

Here is the shader network.

Apply this shader to the snowflakes in a seperate render layer. This will be the motion vector pass

For the motion vector pass, enable Motion Blur in Arnold's render settings.

This will give each snowflake an RGB value.


However there is a problem. We do not want the snowflakes to be motion blurred, we just want them to show the motion vectors.

To stop each slowflake being rendered with motion blur, click the Ignore Motion Blur option in the Override tab of the Arnold render settings

That will give snowflakes with opacity and motion vector information in RGB

One more problem remains - the position of the particle at the time when motion blur is calculated is not the same as the position of the snowflake when the beauty pass is rendered. To fix this, select Start on Frame in the Motion Blur options in the Arnold render settings.

Now, into Nuke.

Load the rendered beauty pass and the motion vector pass. Each snowflake should overlap perfectly (if not, check the Start on Frame option)

Combine the two renders by using a Shuffle Copy node.
Shuffle R -> u
shuffle G -> v

Now use a VectorBlur node to produce the motion blur effect

Thursday, 19 November 2015

High Resolution Cloth Simulations

Here I will describe the method I have been using to create high resolution cloth simulations, based upon low resolution pre-vis cloth. This method is derived from the work of David Knight - thanks David!

1. First, create a medium resolution poly mesh which we will use to create the low res sim.

In my example I have created a mesh with 80 x 160 faces. The mesh MUST be proportionate to the number of faces (i.e. 2:1 in my case) this is because nCloth works better with square faces.

2. Duplicate the mesh. We will use this second mesh to 'pull' the cloth around the scene. Select around 5% of the faces from the leading edge of the Puller mesh. Invert the selection and delete the other faces. We should be left with a narrow strip of faces which exactly overlap the leading edge of the cloth.
 These are the faces we want to keep

3.  Make the original mesh a nCloth.

4. Select the vertices of the nCloth that correspond to the Puller object and then shift select the Puller mesh and create a Point to Surface nConstraint.

5. We want the nConstraint to have low strength, so that the puller gently guides the cloth through the scene. I have used values:
Strength = 0.05
Tangent Strength = 0.0.5

6. We want to animate the Puller mesh now. You can attach it to a motion path or just keyframes, it doesn't matter really. Remember that the faster the cloth moves through the scene, the more sub-frame samples you will need to keep the cloth behaving nicely. If the motion is too jerky the cloth will go crazy. Keep the animation as smooth as you can.

7. Add some noise to the cloth. No cloth will behave perfectly in reality, so add some noise to your simulation. One way to do this is to add a texture deformer to the Puller mesh.

8. Select the Puller mesh. Create a Texture Deformer. Set the deformer's Direction to Normal. In the Texture slot, assign a Noise texture.

9. We don't want to have the Texture Deformer to act on the Puller mesh at the start of the simulation, but rather have it gradually ramp up to full strength over, say, 25 frames. To do this, key the Envelope attribute on the Texture Deformer.

10. Set the Texture Deformer's Offset to be half of it's strength, but in the opposite direction. This will keep the Puller mesh 'centered'. To do this, apply an expression:


 11. Set an expression in the noise texture Time attribute:


This will make the noise texture flow over time.

12. Add some wind, gravity or other forces if you like. Now simulate!

13. Now we have a low resolution mesh. We need to make a high resolution version, but with extra details.

14. First thing to do is to apply a Smooth to the low res mesh. Mesh > Smooth, and give it 2 divisions. In my example, this gives me a mesh with ~200,000 faces.

15. Export this mesh as an alembic cache. Pipeline Cache > Export Selection to Alembic. This is quite slow! Save your scene as LowRes.

16. I recommend that you do the next steps in a fresh scene. Not only will this be faster, lighter and easier to organise, but it will be much easier to go back to the Low Res scene at any time and re-export any changes you need to make really easily. Once re-exported, you can very easily re-import the Alembic Cache file in the High Res scene, without any fuss.

18. In a new scene, import the Alembic cache. Duplicate it. Make the duplicate a nCloth object.

19. Constrain the nCloth to the Alembic mesh. Select the cloth, then the Alembic mesh and then create an Attract to Matching Mesh nContsraint.

20. Again, we want the constraint to 'guide' the cloth, rather than drag it too strongly. Here are the settings I use, but, of course, it will depend on the scene scale, and what you want the cloth to do.

Notice the Strength Drop Off ramp. This allows the cloth to move freely when it is near to the Alembic guide, but the constraint kicks in as the cloth moves away from the guide.

21. Now simulate this High Resolution cloth. Hopefully you will see that is follows the Alembic guide quite closely, but will also have some extra details. I have not changed any nCloth attributes apart from self-collision width. All the motion is made with the constraints.

Here is one I made earlier

High Resolution nCloth test from Daniel Sidi on Vimeo.