RSL2
|
IntroductionTo enable patterns based on noise to "stick" to the ellipsoids of a Blobby, shaders can access a parameter named Pref that contains a copy of the standard P global variable transformed by a user supplied matrix. For example, in rib we might define a volumetric Blobby and its associated Pref matrices as follows. Blobby 3 [8 1001 0 1001 16 1001 32 0 3 0 1 2] [1 0 0 0 0 1 0 0 0 0 1 0 0.5 0.2 0.0 1 1 0 0 0 0 1 0 0 0 0 1 0 0.9 0.6 0.0 1 1 0 0 0 0 1 0 0 0 0 1 0 0.5 -0.5 0.0 1] [""] # Generally the Pref matrices WILL NOT # match the ellipsoid transforms. "vertex mpoint Pref" [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]
Although the matrices of the blobs will change during an animation, say a Blobby
driven by a Maya particle system, the values of the
vertex mpoint Pref
matrices generally remain constant. For convenience they are shown above as indentity
matrices.
Detailed nformation about this topic can be found in Pixar's
Application Note #31.
class no_swimming(varying point Pref = 0) { float fw = max(sqrt(area(P)), (2e-6)); float ns = wnoise(Pref, fw, "octaves", 5, "lacunarity", 1.8); ns = (1 + ns) * 0.5; Oi = ns * VolumeField; Ci = Oi * color(0,0,0); } } As shown in figure 1 the two moving ellipsoids do not exhibit swimming noise patterns. However, once they begin to blend with the stationary ellipsoid their patterns show a considerable amount of stretching. Figure 1 |
Soft Noise ShaderThe "soft noise" shader presented next follows a similar approach to PRMan's built-in support for reference coordinate systems (aka Pref) but without supplying a "vertex mpoint Pref" primvar. Instead, the shader reads two user attributes, namely, "matrices" and "tumble". AttributeBegin # Generally these matrices MUST match the # ellipsoid transforms of the Blobby. Attribute "user" "matrix[3] matrices" [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0.75 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0.0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 -0.75 0 1] # Arbitary x,y,z rotations that tumble the noise # pattern for each ellipsoid. These values generally # remain constant during and animation. Attribute "user" "float[9] tumble" [ 20 -30 200 230 150 30 166 88 180] Surface "softnoise" "float maxdist" 1.0 "float Kd" -1 #Surface "no_swimming" Blobby 3 [8 1001 0 1001 16 1001 32 0 3 0 1 2] [1 0 0 0 0 1 0 0 0 0 1 0 0 0.75 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0.0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 -0.75 0 1] [""] AttributeEnd Figure 2 shows the shader also exhibits sticky patterns but with far less distortion of the pattern when the ellipsoids blend. Because the shader applies unique tumble angles to the "matrices" data before calculating the noise pattern it avoids the "cloned" look seen in figure 1. Figure 2 |
Soft Noise Algorithm
The shader relies on receiving an array of matrices via a user
attribute named "matrices" (during an animation the values of the user attribute
will match the changing values of the ellipsoid transformations). The shader
also receives an array of floats from a user attribute called "tumble".
Listing 1 (softnoise.sl)
|
© 2002- Malcolm Kesson. All rights reserved.