Looks are the next incarnation of shaders. While a Look does include a shader, it also includes other information, like a preview image, a text description, and elements that allow it to be presented and accessed with a graphical interface (on systems for which one exists). The Look shaders are much more general-purpose than previous shaders. They can produce an enormous range of effects thanks to more parameters, and more interesting and powerful ones. They antialias well over a greater range of conditions. They have a generous selection of built-in projections. They can be applied to arbitrary geometry at arbitrary scales.
You can get an idea of their versatility by checking out the links below, which contain thumbnail images of the Looks in all the libraries. Within a library, if you'd like to see the RIB that generated the surface click on the Look name.
If you're a Toolkit user, you can check out the files themselves in the /usr/local/look/examples directory. The *.rib files contain the RIB information that created the corresponding *.tif images. To get information on a Look and its parameters you can use the lookinfo utility.
One advantage of Looks is that they provide a rich set of controls. While some Looks use just a few basic parameters (which nonetheless allow a wide range of effects), others have a dozen or so. Many Looks have parameters tailored for a specific effect. Some woods, for example, allow you to control the wood and grain colors separately, as well as a stain color. Other Looks are designed to be extremely general: you can use your own maps to define areas of shininess, tranparency, color, and displacement, all in the same Look. Another provides you with two sets of general controls, and a third set to determine how to mix the two.
Some Looks can also be combined (Reliefs and material Looks, like Wood or Metal) to provide different effects. These highlight the distinction between a surface's light-reflecting characteristics and its bumpiness. The Material Looks control things like color, transparency, and smoothness, while Reliefs only bump a surface in different ways, and have no controls for anything else. So combining the two can create a rich surface texture with just a few mouse clicks.
To use Looks in Alias you'll want to have the ATOR package. This includes Glimpse, an editor for both Looks and shaders. Refer to the Glimpse documents for more on this.
Using a Look in your code is done in the same way as using a shader. For example:
This C code using the Polkadot Look
{
float density;
static RtColor bcolor = {0.7, 0.6, 0.8};
static RtColor dcolor = {0.6, 0.02, 0.02};
RiTransformBegin();
RiDeclare("DotColor", "uniform color");
RiDeclare("DotDensity", "uniform float");
density = 0.6;
RiColor(bcolor);
RiScale(15.0, 15.0, 15.0);
RiSurface("_VFX_MStarter|Pattern|Polkadot|pxs00016",
"DotColor", dcolor,
"DotDensity", &density,
RI_NULL);
RiTransformEnd();
}
produces this RIB
TransformBegin
Declare "DotColor" "uniform color"
Declare "DotDensity" "uniform float"
Color [0.7 0.6 0.8]
Scale 15 15 15
Surface "_VFX_MStarter|Pattern|Polkadot|pxs00016"
"DotColor" [0.6 0.02 0.02]
"DotDensity" [0.6]
TransformEnd
You'll find a full-blown example of using Looks in C in the file balltest.c.
Use the table below to correlate different kinds of Looks with their filenames and RIB Surface call paths. All the Look masters are in /usr/local/prman/look/masters.
This section contains information that doesn't appear when you query a Look master file (*.vma) using lookinfo. This takes the form of flag and parameter descriptions not present in the master, and information about how some shader elements relate to the RenderMan Interface.
There are five subtypes:
projected: A 2D material that is applied to objects through one of the available projections. It is selected with the Projection parameter (see below for a description of this).
solid: This is a 3D material: objects appear to be carved out of a solid block of this material.
projectedSolid: This is a solid 3D material that may also be applied like a 2D material by selecting the appropriate projection with the Projection parameter.
classic: A material that has no spatially varying characteristics. Its appearance depends only on the lighting and other qualities inherent in the material.
custom: This material has some type of projection peculiar to its unique functionality.
This section describes the various flags used in the Look masters.
Shd0, Shd1, ... Shd5
This indicates which shadow maps the shader can use.
LightType
There are seven lighttypes:
ambient: An ambient light.
distant: A distant light: the light rays are parallel, as though from an infinitely distant source.
point: The light emanates from a single point in space sending rays radially outward from their origin.
spot: A point light for which the light is constrained to shine only in one general direction.
sky: An environment light: a light source designed to produce specular reflections in shiny surfaces.
custom: A light that has its own peculiar functionality.
area: unused
UsesST
This indicates that the Look uses the current
s and t from the graphics state.
UsesCs (Surface shaders only)
This indicates that the
shader uses the current color as set by Color.
UsesOs (Surface shaders only)
This indicates that the
shader uses the current opacity as set by Opacity.
SetsOi (Surface shaders only)
This indicates that the
shader changes the opacity; also, it implies that Sides should be set to 2.
CanMoveP (Surface and Displacement shaders only)
This
indicates that the shader can displace the surface.
UsesLightColor (Light shaders only)
This indicates
that the light has and uses the LightColor parameter.
UsesTime
This indicates that the shader uses time.
The Stand In Shader is simply a recommendation of what shader to use in place of the Look. You might use this to speed up rendering while concentrating on objects' orientation, or position, for example. This can be one of the following:
For surface shaders -- constant, defaultsurface, matte, metal, null, plastic, shinymetal, paintedplastic
For displacement shaders -- nodisplacement
For light shaders -- ambientlight, distantlight, noarealight, pointlight, spotlight
The Look parameters provide control of the visual aspects specific to a particular shader. Examples of these are dimensional values that control the size of something the shader produces or additional colors besides any default ones. Dimensional parameters are always in meters or radians and color parameters are in RGB. Below are a few parameters whose descriptions bear some elaboration over that found by using lookinfo.
Surface shaders
Projection Parameters
| SL Name | Type | Range | Default |
|---|---|---|---|
| ProjRadius | Control | [none-none] | [1.0] |
| STMatrix0 | Point | [a valid 2D | [1.0, 0.0, 0.0] |
| STMatrix1 | Point | xfrm matrix] | [0.0, 1.0, 0.0] |
| Projection | Selector | [0-10] | [0] |
For surface shaders of the Projected or ProjectedSolid SubType, these parameters control what type of 2D to 3D projection is used, any applicable radius used by the chosen projection, and a 2D transformation matrix to be applied to the 2D appearance.
ProjRadius value is in meters. Those projections that
make use of the ProjRadius parameter are: Box, Spherical,
Cylindrical, and BoxSpherical. STMatrix parameters make up a 2x3 (or 3x2, depending on
your viewpoint) affine transformation matrix allowing for rotation, translation,
and scaling to be applied to the shader's 2D appearance before it is projected
into 3D. Its default value is the identity matrix. Below are descriptions of the available projections:
Solid (-1) -- The Solid projection is a 3D projection. In this case, a Look creates a potentially infinite volume filled with some material, like wood, or marble, for example. Depending on where an object is in shader space, it will look like it's carved out of a different part of the tree, or marble block.
This projection is not available for the Projected SubType.
Planar (0) -- The Planar projection treats the Look as a flat sheet: a "slide" if you will, to be projected onto a surface's front. Another way of visualizing the effect on the object is this: if you imagine that the Look is a sheet of paint, using this projection is like pushing the object through the sheet. The top, bottom, and sides get "smeared," and the back face has the image reversed. Using the planar projection on an object whose shape is decidedly not flat (a sphere, for example) can produce unexpected (but entertaining) effects.
This projection is not available for the "Projected" SubType.
AutoPlanar (1) -- The Autoplanar projection treats the Look as a flat sheet that gets "pressed onto" every face of a surface. Suppose you want to apply a Look to a pyramid. Using this projection the Look would be applied individually to each of the pyramid's faces, based on each face's orientation. However, in exchange for the generality of this projection, you sacrifice control over individual faces. Autoplanar projections can produce unexpected (but entertaining) effects when used on curved surfaces.
Box Perspective (2) -- This applies a Look from six directions, as if there were a large box around the object with a projector pointing inward attached to each side. The difference between this and Autoplanar is that Autoplanar applies a projection from as many directions as there are faces, instead of just six directions.
Spherical (3) -- This projection applies a Look as if it were a spherical sheet that got "shrink-wrapped" onto the object. It covers objects equally from all directions. The size of the sphere is determined by the ProjRadius parameter.
There is one seam, at the back of the sphere. While there is no distortion at the seam, there is distortion toward the "poles." Using this projection on an object whose shape isn't really spherical can create unusual results.
This projection allows seamlessly tiling textures to match at the seams.
Cylindrical (4) -- This shrink-wraps a Look in the shape of a cylinder onto an object. As you would expect, the sides get covered equally, but the top and bottom get the very top of the Look smeared across them.
The cylinder is oriented so that you see the object's front through the front of the cylinder. The cylinder's radius is determined by the ProjRadius parameter.
There is one seam, at the back of the cylinder. While there is no distortion at the seam, there can be distortion elsewhere on anything but a perfect cylinder.
This projection allows seamlessly tiling textures to match at the seams.
ST (5) -- This projection matches the s,t space of the surface to that of the texture map. The s,t space can be transformed using the STMatrix parameter.
Box Planar (6) -- This is like the Box projection, except that instead of the box having 6 square sides, the box has 6 planes of infinite extent for sides. Additionally, the box's orientation is based on the object's surface orientation.
Box Spherical (7) -- Imagine a sphere with six copies of a texture on it, each texture occupying a sixth of the sphere. This then gets projected onto the surface. The size of the sphere is determined by the ProjRadius parameter.
There are 12 seams, where the six copies of the texture abut each other. On spheroidal objects there will be some distortion at the seams, but in general this is noticable mostly when there are straight lines in the Look. This projection allows seamlessly tiling textures to match at the seams.
Cyl No Stretch (8) -- This is like the Spherical projection, but the top of the texture is left "open" when wrapped around the object, creating a cylindrical shape. And here again, areas of the texture are kept constant at the expense of things matching up at the seam. Use this on objects that are taller than they are wide.
The cylinder is oriented so that you see the object's front through the front of the cylinder. The cylinder's radius is determined by the ProjRadius parameter.
There is one seam, at the back of the cylinder. The farther you go from the seam, the less the distortion.
Sph No Stretch (9) -- This applies a texture as if it were a sheet of paper you were trying to wrap spherically around the object. Let's say there were small bricks on this paper. The bricks would be the same size all over the object, but you couldn't count on things matching up at the seam, and you'd have to cut some of the paper off to make it fit. This points up the difference between this projection and the Spherical projection. With that, the bricks' size would vary across the surface, but they would match at the seam, and the whole texture would be present. However, with Sph No Stretch the poles should look OK if the view is more or less toward the equator.
The projection sphere is oriented so that you see the object's front through the front of the sphere. The size of the sphere is determined by the ProjRadius parameter.
There is one seam, at the back of the sphere. The farther you go from the seam, the less the distortion.
Centered ST (10) -- This is like the ST projection, but uses a coordinate system where the origin in ST parameter space is the center of a patch. This way, when applying 2D ST matrix transformations no additional translation need be interposed. Also, this means that mappings get rotated about the center. By contrast, rotating a standard ST mapping will cause the texture to pivot on the corner and rotate off the patch.
Reflection Parameters
| SL Name | VFXType | Range | Default |
|---|---|---|---|
| RefName | Texture | n/a | "" |
| EnvName | Texture | n/a | "" |
| EnvSim | Switch | [0,1] | [1] |
| EnvSimFreq | Control | [none-none] | [1.0] |
| Ambient | Control | [0-none] | [1.0] |
| Diffuse | Control | [0-none] | [1.0] |
| Specular | Control | [0-none] | [1.0] |
| Roughness | Control | [0-none] | [1.0] |
| Environment | Control | [0-none] | [1.0] |
| EnvFilterSize | Control | [0-none] | [1.0] |
The RefName and EnvName parameters allow the user to specify a flat reflection map or an environment map texture to the shader for non-lightsource surface reflections. The EnvSim switch allows a simulated environment reflection generated by the shader to be used instead. The complexity of the simulated environment (essentially noise based on the surface normal) is controlled with the EnvSimFreq parameter. If EnvSim is "on" (1), a simulated environment reflection will be generated. If the EnvName parameter is other than "", the specified environment map will be used regardless of the EnvSim setting. If RefName is some value other than "", the specified reflection map will be used regardless of the EnvName value or EnvSim setting.
The reflection characteristics of a surface are a function of the surface material and so are generally fixed for a given material. The Ambient through EnvFilterSize parameters are the scalars used to alter the normal reflection characteristics produced by the shader.
Intensity Parameters
| SL Name | Type | Range | Default |
|---|---|---|---|
| Falloff | Control | [n/a - 4] | [0.0] |
| FalloffDistance | Control | [0-none] | [1.0] |
| Brightness | Control | [0-1] | [1.0] |
The Falloff parameter adjusts the light's falloff profile: the shape of the brightness curve as a function of distance from the light. Falloff values greater than 0 cause the light to fade with distance: Falloff is the inverse distance exponent (specifically, a value of 2 will produce an inverse-squared falloff). Behavior for values less than 0 is light dependent. A Falloff of 0 causes no change in brightness with distance.
When the Falloff parameter \xad 0, the FalloffDistance parameter sets the distance from the light at which the light's brightness is the value of the Brightness parameter (see below). The FalloffDistance value is in meters. When there is no falloff (the Falloff parameter = 0), FalloffDistance is unused.
The Brightness parameter sets the light's Brightness at the FalloffDistance.When there is no falloff (the Falloff parameter = 0), Brightness sets the characteristic brightness of the light: the light's intensity.
Alternatively, each of these parameters may take on a shader specific meaning. For example, Falloff my select from among a set of falloff profiles or have some meaning other than the inverse distance. Additionally, there may be more than one FalloffDistance or Brightness parameter. A set of FalloffDistance parameters might be used to indicate specific points of interest in the falloff profile. A corresponding set of Brightness parameters might then be used to control the brightness at each of those points. However, it must be noted that each of these original parameters must be present. Specifically, FalloffDistance must set the light's intensity, Brightness must scale the light's intensity, and when Falloff is 0, the light's falloff profile is flat: there is no falloff.
MaskShape Parameter
| SL Name | Type | Range | Default |
|---|---|---|---|
| ConeAngle | Control | [0-Pi/2] | Shader Dependent |
The ConeAngle parameter defines the cone of maximum extent of the light produced by a Spot subtype light. i.e. any point that may be illuminated by the light will be within a cone of ConeAngle apex angle. Only Spot subtype lights use the ConeAngle parameter. Other light subtypes will use other MaskShape category parameters that are specific to the shader.
MaskProjection Parameters
| SL Name | Type | Range | Default |
|---|---|---|---|
| Projection | Selector | [0-5] | [0] |
| ProjRadius | Control | [0-none] | [1.0] |
| STMatrix0 | Point | [a valid 2D | [1.0, 0.0, 0.0] |
| STMatrix1 | Point | xfrm matrix] | [0.0, 1.0, 0.0] |
For lights of the "Projected" SubType, these parameters control what type of mask projection is used and a 2D transformation matrix to be applied to the 2D mask. The projections available (in rank 0-5 order) are: Planar, Box, Spherical, Cylindrical, BoxPlanar, and BoxSpherical. The ProjRadius parameter acts as a scalar to the normal light-to-mask distance defined internally to the shader and so all projections make use of it. The STMatrix parameters make up a 2x3 (or 3x2, depending on your viewpoint) affine transformation matrix allowing for rotation, translation, and scaling to be applied to the 2D mask before it is projected into 3D. Its default value is the identity matrix.
Penumbra Parameter
| SL Name | Type | Range | Default |
|---|---|---|---|
| Penumbra | Control | [0-none] | [1.0] |
For light source shaders which have some sort of "mask" that limits their illumination, a penumbra is created due to the light source (bulb) having a non-zero surface area. The bulb shape, and therefore the normal extent of the penumbra, is a characteristic determined within the shader. However, the user may alter this normal penumbra by scaling the bulb's, and therefore the penumbra's, extent with the Penumbra parameter. Distant, Spot, and Point subtypes may have the Penumbra parameter.
Shadow Parameters
| SL Name | Type | Range | Default |
|---|---|---|---|
| Shd0 | String | n/a | [""] |
| Shd1 | String | n/a | [""] |
| Shd2 | String | n/a | [""] |
| Shd3 | String | n/a | [""] |
| Shd4 | String | n/a | [""] |
| Shd5 | String | n/a | [""] |
The Shd parameters are used to specify to the shader the shadow map or shadow maps to use. Spot and Distant subtypes will use the Shd0 parameter, and Point subtypes may use up to all six Shd parameters.
Displacement Parameter
For Looks that use a displacement, the Displacement parameter will be present. There will also be one or two parameters to set the displacement's magnitude(s). This is the maximum excursion up or down (or both) allowed by the shader. The parameter names are shader-specific, but are commonly something like GrooveDepth, or BumpHeight and BumpDepth, and so on. Use lookinfo to find the parameter name(s) in a specific Look. If Displacement is set to 1.0, the "shader" space displacement bound should be set to the largest absolute value of the other parameter(s). So, for example, in the Wavy Look if BumpHeight is set to -0.8, Displacement should be set to 0.8.
Here's an example of how this is handled in C using the RiAttribute call.
{
RtFloat height;
char *shader = "shader";
height = fabs(BumpHeight);
RiAttribute("displacementbound",
"coordinatesystem", &shader,
"sphere", &height,
RI_NULL);
}
TimeMatrix Parameters
| SL Name | Type | Range | Default |
|---|---|---|---|
| TimeScale | Control | [none-none] | [1.0] |
| TimeOffset | Control | [none-none] | [0.0] |
The TimeScale and TimeOffset form a 1x2 transformation matrix used to transform the shader time variable specified by RiShutter() to seconds as well as account for any user applied scaling and offset of time. Its default is the identity matrix.
Antialias Parameter
The AntiAlias parameter controls the overall amount of filtering done by the shader. Doubling the value of AntiAlias will double the filtering widths and attenuation ranges used within the shader (including texture access functions). Its value generally increases (or decreases) by a power of two.
The RiShutter Option
The RenderMan Interface option specified by the first value of an RiShutter() call is passed into the shader as the variable time. A shader may make use of this value by multiplying it by the TimeMatrix to get the current shader time.
Coordinate Systems and Transformations
Surface shaders
The application controls the position, orientation, and scale of a shader's appearance by transforming the shader space in which the surface shader is called in the RIB file. By bracketing the RiSurface() call within a RiTransformBegin()...RiTransformEnd() block, the shader space is isolated and can be adjusted without influencing other coordinate transformations. The shader space must be scaled to units of meters as well as account for any other user applied scaling. The orientation of this space is such that +Y is the "up" direction, +Z is the "forward" direction, and +X is to the "right". Projections that produce a seam where opposite sides of an appearance meet are oriented so the seam is at +Z.
The "worldspace" coordinate system must also be defined for a shader so it may, if necessary, obtain information about the world space in which it is operating. This space is primarily used for environment reflections but may have other uses in specific shaders as well. Regardless of the "world" space the application actually uses for modeling, a separate "worldspace" coordinate system must be defined using an RiCoordinateSystem("worldspace") call in which +Y is "up" and the X and Z axes are in the horizon plane. Ostensibly, +X should be to the "right" and +Z should be "forward" if these directions can at all be defined. In addition, "worldspace" should be in units of meters.
Displacement shaders
The application controls the position, orientation, and scale of a displacement shader by transforming the shader space in which the displacement shader is called in the RIB file. By bracketing the RiDisplacement() call within a RiTransformBegin()...RiTransformEnd() block, the shader space is isolated and can be adjusted without influencing other coordinate transformations. The shader space must be scaled to units of meters as well as account for any other user applied scaling. The orientation of this space is such that +Y is the "up" direction, +Z is the "forward" direction, and +X is to the "right". Projections that produce a seam where opposite sides of an appearance meet are oriented so the seam is at +Z. Displacement typically occurs in the surface normal (N) direction but is shader dependent.
The "worldspace" coordinate system must also be defined for a displacement shader in the same way as for surface shaders so it may, if necessary, obtain information about the world in which it is operating.
Light shaders
The application controls the position and orientation of a light source by transforming the shader space in which the light shader is called in the RIB file. By bracketing the RiLightSource() call within a RiTransformBegin()...RiTransformEnd() block, the shader space is isolated and can be adjusted without influencing other coordinate transformations. The orientation of this space is such that +Y is the "up" direction, +Z is the "forward" direction, and +X is to the "right", so that Spot and Distant light subtypes will shine in the +Z direction. Additionally, the Spot and Point subtypes shine from the origin. Mask projections that produce a seam where opposite sides of a light's "mask" meet will be defined in the shader so the seam is at -Z (this is opposite the seam location for surface and displacement shaders).
The "worldspace" coordinate system must also be defined for a light shader in the same way as for surface shaders so it may, if necessary, obtain information about the world in which it is operating.