RfM
|
Introduction
This tutorial provides three examples of how primvars can be set up and used with RfM and HyperShade.
The reader should refer to the tutorial
RIB/RSL: Using PrimVars for basic information about primvars.
Example 1 - using a "float" primvarSetting Up the Material
1 In HyperShade create an instance of Blinn and assign it to several surfaces.
2 Scroll to the "Common Material Attributes" tab,
3 Rename the "Rman Prim Var Float Attibute" to "Dc" as shown in figure 2.
|
Setting Up the Surfaces
4 Copy and paste the MEL proc, shown in listing 1, into Maya's script window. Listing 1
|
5 Select the surfaces to which Blinn was assigned, PointsGeneralPolygons [1] [4] [0 1 3 2] "P" [xyz data...] "constant float Dc" [0.5523]
Note the prefix acts as a directive to RfM to emit the attribute values as a primvar in the rib stream.
Naming ConventionsThe name assigned in step 3 must match the name of the attribute assigned to geometry in step 5. |
Example 2 - using a "color" primvar
Setting Up the Material
1 In HyperShade create an instance of Blinn and assign it to several surfaces. |
Setting Up the Surfaces
4 Copy and paste the MEL proc, shown in listing 2, into Maya's script window. Listing 2
|
5 Select the surfaces to which Blinn was assigned, PointsGeneralPolygons [1] [4] [0 1 3 2] "P" [xyz data...] "constant color C" [0.520171 0.486881 0.625127] 6 Finally, render the scene.
|
Example 3 - using a "string" primvar to randomize texture mapping
Unlike the previous examples there is no need to use a primvar utility node because the
shader parameter, "XXX_fileTextureName",
is automatically "exposed" (ie. inserted into the rib stream) as a result of connecting a
shader "RMSGPSurface1_rfm" "MAP_fileTextureName" "parameter uniform string" Default value: "" "diffuseGain" "parameter uniform float" Default value: 1.000000 "sheen" "parameter uniform float" Default value: 0.000000 "sheenTint" "parameter uniform float" Default value: 0.500000 was generated by the using the utility application "sloinfo" on a compiled instance of RMSGPSurface that had its "Surface Color" connected to a File node named "MAP", figure 5. |
|
This example demonstrates how an arbitrary number of images can be used as texture maps that are randomly assigned to a selection of surfaces. Thus one instance of a material, say, RMSGPSurface can be used to texture many objects with each being randomly assigned a texture. Assumptions
For simplicity the procs shown in listing 3 assume the source images for the texture maps, say, "iris.tif",
"rose.tif" etc have been moved to the Maya project's "images" directory. The procs further assume
that when the images are converted to textures the .tex files will be stored in the same directory
as the source images. The
users "images" directory will probably contain image files that are not intended to be used for
randomized texture mapping. One of the procs queries a text file ("textureDB.txt")
to identify the images that should be used as source maps for the randomization.
Setting Up the Material
1 Move your image maps to your Maya project's "images" directory. images/iris.tif images/rose.tif images/lily.tif images/magnolia.tif
4 Create an instance of a material such as RMSGPSurface or Blinn. |
Setting Up the Surfaces
8 Execute the MEL procs shown in listing 3. string $paths[] = getTexnames("textureDB.txt"); string $textures[]; if(size($paths) > 0) { $textures = makeTextures($paths); addStringPrimVar("MAP_fileTextureName", $textures); } The surfaces should render with randomized textures, as shown in figure 6. |
|
Listing 3
|
© 2002- Malcolm Kesson. All rights reserved.