OSL shaders written for use with rendering systems such a VRay can directly refer tp 'uv' texture coordinates when generating a surface pattern. However, using 'u' and 'v' with RenderMan will not work as expected. For example, figure 1 shows the effect of using a shader called "use_uv" (listing 1) on a nurbs torus with 8 x 8 "divisions".
Listing 1 - use_uv.osl
RenderMan uses it's own unique texture coordinate system, designated 'st', and as such OSL shaders that generate 2D texture patterns must reference 's' and 't' as primvars. Some basic information about primvars can be found in the tutorial "RIB: Introduction to Primvars". An OSL shader that uses 'st' coordinates for a surface pattern (listing 2) produces the correct effect - figure 2 (listing 2).
Listing 2 - use_st.osl
Note the use of the metadata tag.
Avoiding 's' & 't' Seams
Instead of using the 'st' texture coordinates directly their values can remapped so that the "seams" where 's' and 't' wrap from 0.0 to 1.0 can be avoided. For example, listing 3 and figure 3.
Listing 3 - use_st.osl (remapped)
© 2002- Malcolm Kesson. All rights reserved.