MTOR/Slim - Mapping techniques
RenderMan permits texture-mapping,
where an image (file texture) is mapped (fitted) to a surface or a part of
it. In addition, RenderMan also makes use of computed maps to create
shadows and reflections.
In this (last) class, we'll look
at how to accomplish the following using MTOR/Slim:
- texture mapping
- shadow generation
- planar-reflection mapping
- environment mapping [curved
You typically use an 'ImageFile'
Slim appearance to read in an image from disk and use it as a texture map
in an R'man shader. Slim in addition also lets you derive texture-mapping
coordinate information from a Maya utility shading node called 'place2dTexture'.
So here's how to match Maya's texture-coordinates in RenderMan:
- create a 'place2dTexture' node
in Maya [using hypershade]. We'll be using this node to specify mapping coordinates
for our RenderMan shader
- create a Slim shader that will
use a texture map [eg. create a 'Blinn' node] and attach it to a surface
that you will be texturing. Also, create a light source
- For the shader node's 'color'
input, choose an 'ImageFile' node connection
- Open up the 'ImageFile' node
and do two things: specify an image to be read in using the file-browser,
and also choose a 'MayaUV' node connection for the 'manifold' parameter.
Also, click on the little panorama icon next to the input image file name,
and choose the option that creates a texture image from the file image. RenderMan
uses its own format for texture maps, that is why common image formats need
to be converted to the R'man format
- Open up the 'MayaUV' node, and
turn the STMatrix0 and STMatrix1 parameters into expressions [click on the
'chiclet' to the left of these params and choose 'Expression']
- Type [st0 place2dTexture1] and
[st1 place2dTexture1] into the expression fields for STMatrix0 and STMatrix1
respectively. This tells Slim that values for these attributes [which specify
texture placement for our ImageFile node and hence for the Blinn node] will
be specified through Maya's place2dTexture node
- render. You should see your
image mapped on to your surface.
- make changes to the place2dTexture
node in the Attribute Editor or channel box , re-render. You will see that
changes made in the place2dTexture node will be propagated up our node chain
and will affect the render. Eg. if you specify a texture rotation, the texture
map will appear rotated in the rendered image. This technique lets you use
Maya as a front-end to do all your texture placement and carry the results
over to RenderMan
Shadow maps are an efficient alternative
to raytracing which is usually computationally expensive.
The idea is to create a light source
(point, spot or directional) in Maya and attach a corresponding Slim shader
to it, and turn on the shadow generation feature. Note that a spotlight or
a directional light requires the computation of just a single shadowmap while
a pointlight requires SIX maps.
- create a few Maya objects, eg.
a plane and a sphere that will cast a shadow on the plane. Make sure for
the shadow-receiving object [in our case,the plane] that you check OFF the
box in the Attribute Editor that says Render Stats -> Casts shadows. If
you omit to do this, the shadow will not be visible!
- create a light [eg. directional
light] in Maya, orient it appropriately
- import an MTOR lightsource
appearance called mtorDirectionalLight [do 'Import Appearance', then look
in the lib/shaders area under the 'rat' tree] , attach it to the Maya light.
Note that this is a 'light shader' which we're attaching to a light, just
as we would attach a surface shader to a surface
- open up the mtorDirectionalLight
shader, double click on shadow parameters icon [which looks like three 'chiclets'
overlapping and offset from each other] and set the value of 'Make Shadow
Map' to 'Once per job' or 'Every Frame' depending on whether you have a static
scene or an animation. Also, click on the little panorama icon, and choose
'Refer to' and specify 'shadowmap' [this tells Slim that the shadow will
be generated using the shadowmap that will be computed in a pre-pass]
- render. You will see that the
sphere is casting a shadow on the plane.
Here are the steps to achieve soft
- create a plane (to receive the
soft shadow) and a sphere on top (to cast the shadow)
- create a Maya spotlight, position
it over the sphere. Be sure to place the handle for the spotlight [turn on
the handles using 't'] near the sphere, since MTOR uses this to estimate distances.
If the handle is too far away, the shadow will not look soft
- select [pick] the spotlight
- set RenderMan -> Attributes
-> Soft Shadows. This will create two extra Maya attributes for the spotlight,
and bring up a small dialog box where you can specify the 'size' of the soft
shadow and the number of shadow map passes to compute to obtain a soft shadow
[the maps created in these passes are averaged together to get the softness].
8 for the size and 4 for the no. of passes are good values for these two
- create an 'mtorSpotLight' appearance
[Create Appearance -> Light -> Spot], attach it to the spotlight.
- enable 'Create Shadow Maps'
for the appearance
- In Maya, using the AE
, disable [check OFF] 'Render Stats -> Casts shadow' on objects
that only receive (but don't cast) shadows, in our case, the plane.
- render. You should see a soft
shadow being cast on the receiving object.
Use reflection-mapping (and not environment-mapping)
when you have a relatively planar, shiny object on which you want nearby
objects to be reflected. Note that reflection maps are camera-dependent,
so for an animating setup you need a map for each frame where there is relative
- create a flat object that will
receive a reflection and another object near it [eg. a sphere] to cast a
- create a light source (eg. a
directional light), position it appropriately
- create an AdditiveFX node, assign
it to the flat object
- create a different shader for
the object that will be reflected, assign that shader to that object
- create a surface appearance,
eg. a Blinn node
- Connect AdditiveFX's Base to
the Blinn node
- Connect a ReflectionMap to AdditiveFX's
ch1 input. The idea is that the AdditiveFX node will layer reflections on
top of the 'base' material
- In the ReflectionMap node, set
calculation frequency to 'Once per job' or 'Every Frame'. Also, choose 'Refer
To' and specify 'reflection map'.
- In Maya, turn off 'Visible in
Reflections' under the 'Render Stats' tab for the shiny surface [our plane].
This is VERY important to do, without it you will not see a reflection!
- render. You'll see a reflection
of the sphere on to the plane underneath
Environment mapping is useful when
you have a curved object (as close to spherical as possible) that needs the
scene around it to be realistically reflected on it.
Alternately, you can create an environment
map yourself from your own images and then have the EnvMap node make use of
it. Once you create such a map [with a .env extension, to follow R'Man conventions],
simply point MTOR to it using the file-browser in the EnvMap appearance.
The neat thing about this is that the sources of the input images can be
anything including photographs, other scanned material, digital art, processed
imagery, rendered images, etc., etc. Eg. if you want glowing Maya objects
to be reflected in your RenderMan renders, the thing to do is to place a
Maya camera in the center of the object that will receive the reflections
[hide that object itself], and render 6 images by orienting the Maya camera
along +X, -X, +Y, -Y, +Z and -Z. These 6 images can now be used to create
an R'Man 'cubical' environment map (see below).
- In Maya, create a curved object
(eg. a teapot) which will reflect the scene around it, and a few more objects
around it to get reflected on to the curved object
- create a light source and place
it appropriately. The location of the reflections will depend on the light
position, in addition to the relative locations of the objects themselves.
It is also a good idea to have some ambient lighting to illuminate all the
- create surface appearances and
assign them to the peripheral objects [the ones that'll get reflected]
- create an AdditiveFX appearance,
assign it to the curved object [the one that will receive the environment
- create a Blinn appearance, connect
it to AdditiveFX's Base channel
- set AdditiveFX's 'ch1' to 'Collect
Reflections' [compare this to the planar reflection mapping where we set this
ch1 channel to 'ReflectionMap']
- create an 'Environment' appearance
[look under the 'Lights' set of appearances]. This node will become responsible
for computing environment maps that will be used for reflecting on to the
- open up the Environment node,
set its type to 'EnvMap'. This will cause a new node of type 'EnvMap' to
be created and hooked up to it. The alternative type is 'Blobby' which computes
a quick but rather inaccurate map.
- open up the EnvMap node and
set the map computation to 'Once Per Job' or 'Every Frame'. Also, set 'Refer
To' to point to 'environment map'
- create a point-light, attach
the Environment shader to it. This light will not be used to light your objects,
it merely serves a placeholder for attaching the Environment appearance.
Also, the environment map will be computed from the light's location, so
be sure to place it at the center of our
- remember to turn off 'Visible
in Reflections' for our shiny, reflecting object.
If you don't, the environment map will be computed to include this object.
Since we're positioning our point light right in the center of this object,
this object is all the env map will contain [as it will obscure all other
surrounding objects], and so the neighboring objects will not appear to reflect
on this object.
- render. What you will see is
the environment around the curved object reflected on it.
There are two kinds of environment
maps that RenderMan recognizes - a 'latlong' map and a 'cubical' map. The
latlong map can be likened to a map projection where a spherical view of the
world has been flattened or unwrapped on to a plane. It is a good choice for
outdoor scenes. In contrast, a cubical environment map is stitched together
from 6 views at the point of projection (front, back, left, right, top, bottom)
and is great for indoor scenes where rooms are usually cubical.
Creating a 'latlong' map:
Creating a 'cubical' map:
- create an image, eg. using Photoshop
- txmake -envlatl inimg
- create six component directional
images [front, right, back, left, up, down]
- txmake -envcube inimg1
inimg2 inimg3 inimg4 inimg5 inimg6 output.env