OSL
|
IntroductionThe features of shading points, such as their position, color and presence, are often determined by their location in the 'st' texture space. For example, listing 1 shows a surface shader that uses the sin() function, based on 's', to generate a cyclic pattern - figure 1. Listing 1 (simple_sine.osl)
Of course, if the shader is attached to geometry that has not been assigned texture coordinates the result of using 's' becomes problematic - figure 2.
Even more unpredictable are geometries, such as a Blobby, that cannot be given texture coordinates - figure 3.
The next section demonstrates that shading according to 'xyz' position, rather than texture coordinates, generates a 3D solid texture. |
A 3D Sinusoidal Texture
Rather than calculating a sine value based on a texture coordinate, such as 's',
the polar coordinate of a shading point (generally a micro-polygon) can be used.
For example, the angular position (theta) of Listing 2 (sine3d.osl)
Figure 5 shows the sine3d shader controlling the color of a blobby. |
Pattern "PxrOSL" "sine3d4" "string shader" "sine3d" "float freq" 34 "float amp" 2 "float offset" -1 "float blur" 0.05 "string spacename" ["object"] Bxdf "PxrDisney" "PxrDisney1" "reference color baseColor" ["sine3d4:resultRGB"] "float specular" [0.5] |
Figure 6 shows the sine3d shader controlling the presence of a blobby. |
Pattern "PxrOSL" "sine3d4" "string shader" "sine3d" "float freq" 34 "float amp" 2 "float offset" -1 "float blur" 0.05 "string spacename" ["object"] Bxdf "PxrDisney" "PxrDisney1" "float specular" [0.5] "reference float presence" ["sine3d4:resultF"] |
© 2002- Malcolm Kesson. All rights reserved.