Musings of a Serial Filmmaker


« Ten Rules For Web Startups | Main | Wong Fu Productions »

Animated Textures With RenderMan

Animated Textures With RenderMan Tutorial

This RenderMan related tutorial shows mainly how to animate RenderMan shaders in Maya. To illustrate this tutorial, I decided to create an Ocean shader animated purely through the use of procedural textures with RenderMan.

This tutorial isn't a guide on how to create a photorealistic ocean shader in any way. No real world ocean effects like frothing and waves collision - none of that. That would be a whole new tutorial on its own.

For some purposes though, this simple effect may be good enough for production. Here's the final clip: http://www.timshim.com/downloads/ocean_demo.mov. The compositing work was quick and dirty - I added in a still image of a sky picture and animated it to match the ocean somewhat. Not very good but better than leaving a black hole for a sky.

So here we go ...

Step 1
Create a NURBS plane. Create > NURBS Primitives > Plane. This will be our ocean surface.

Step 2
Before creating the Shader in RenderMan's RAT, you'll need to add a new Maya attribute to the NURBS plane. Later, we'll link this attribute to the RenderMan shader. To clarify this a bit before going further - the reason for doing this is simply because we are not able to key the attributes directly in RenderMan's Slim palettes. Thus, we'll have to connect it to an external Maya attribute which is keyable (animatable).

Ok. On with the tutorial.

First, select the NURBS plane and in the Channel Box, rename the NURBS plane to 'oceanPlane'. This is to ease remembering the name of the object - we'll need it later on.

In Maya, select the NURBS plane and, from the menu, click Modify > Add Attribute ...

Attribute Name => OceanWaves
Minimum => 0
Maximum => 1
Default => 0

The rest of the options can be left at their defaults. Click 'Add' and we're done here.

Step 3
Now we create the ocean shader.

Open up a new Slim palette from the RenderMan menu and create an Ensemble. RenderMan > Slim > New Palette. In the new Slim palette, File > Create Appearance > Ensemble > Ensemble. Rename this Ensemble to 'Ocean'. This is optional, but good practice for obvious reasons.

Step 4
Double-click the Ensemble to open up its Attribute Editor. Plug in a 'Glass' surface into the 'Surface' attribute. Here are my settings.

Step 5
Now let's add some displacement (or rather, bump) to the shader. Go back out to the Ensemble's attribute panel. Plug a 'Simple' into the 'Displacement' attribute. Here are my settings.

Step 6
Now we'll add a Brownian fractal to simulate the look of an ocean. In the Simple panel, in the Displacement attribute, plug in a 'Brownian' (Pattern > Brownian).

This is where we need to link the 'Fourth Dimension' attribute to the OceanWaves Maya attribute we created in Step 2.

Ok, now there's this quirk with RenderMan's UI that I thought isn't too intuitive. Apparently, for certain panels, like in this example, we are able to 'toggle' between two different interfaces. It isn't apparent at first until you read the Info by clicking on the [i] next to the panel name. In this case, it's the [i] next to 'Brownian Parameters'. Even then, the intructions isn't exactly clear on how to do this toggle.

Here's how. Close the Brownian Parameters area by clicking on the down arrow. Now this time, hold Control and click on the arrow again to open up the Brownian Parameters area. Now we see the other interface.

Now we can input the only line of TCL code needed to link the 'Fourth Dimension' attribute to the OceanWaves attribute of the NURBS plane. Click on the input button to the right of the 'Fourth Dimension' field and select 'TCL Expression'. This is the line of code we need to input in the field: [mattr "oceanPlane.OceanWaves" $f]. 'oceanPlane' is the object name and 'OceanWaves' is the attribute we created for the object earlier. The $f here is important as it tells the shader to update on every frame. And my deductive powers tells me 'mattr' probably stands for 'Maya attribute'.

That's all there is to it. Now your shader is connected to your Maya attribute and when you change or key the OceanWaves attribute, the 'Fourth Dimension' attribute in the Brownian shader will update as well.

Step 7
This is an optional step but I did it anyway. This step simply links the Brownian node to the Specular of the 'Glass' shader. Open up the Slim palette, right click on the Ocean shader and select Call Graph > Graph Children. Middle click the Brownian node and drag the arrow onto the Glass shader. Select 'Specular Strength' from the pop up. Done.

Step 8
Okay, now to animate the OceanWaves attribute. This is simple enough. Select the NURBS plane. In the Channel Box, we see the new attribute 'Ocean Waves' in it. Set a key on frame 1. Then change the 'Ocean Waves' to 1.0 and set another key on frame 50. What I also did is to cycle offset the animation graph so the animation will run indefinitely.

And there you have it. Given it isn't exactly a perfect Ocean simulation but it illustrates how to animate textures with RenderMan in Maya. Thanks for reading, please leave comments or feedback. If you've got a better way of doing this, please let me know and I'll post your feedback as an update to this tutorial. Cheers.

TrackBack

TrackBack URL for this entry:
http://www.timshim.com/cgi-bin/mt/mt-tb.cgi/26

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

timshim.com