RenderMan For Artists #04
Wanho Choi
(wanochoi.com)
RenderMan for Artists wanochoi.com
(Math) Distance between two points
2 1 2 2 1 2 2 _____ ) ( ) (x x y y PQ 2 1 2 2 1 2 _____ ) ( ) (x x y y PQ
•
2D
•
3D
2 1 2 2 1 2 2 1 2 _____ ) ( ) ( ) (x x y y z z PQRenderMan for Artists wanochoi.com
Polygonal Meshes
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin Translate 0 0 10 Rotate 60 1 0 0 Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] WorldEnd .rib x y 0
RenderMan for Artists wanochoi.com
Polygonal Meshes with Colors
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin Translate 0 0 10 Rotate 60 1 0 0 Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "Cs" [0 1 0 0 0 1 1 1 1 1 0 0] WorldEnd .rib
RenderMan for Artists wanochoi.com
Polygonal Meshes with Constant Color Shader
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" "surfaceColor" [1 0 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "Cs" [0 1 0 0 0 1 1 1 1 1 0 0] WorldEnd
.rib
surface myShader( color surfaceColor = color(1,1,1); ) {
Oi = Os;
Ci = Oi * surfaceColor; }
RenderMan for Artists wanochoi.com
RenderMan Help File
RenderMan for Artists wanochoi.com
mix(A,B,x) = A*(1-x)+B*x where 0≤x≤1
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "s" [0 0 1 1] "t" [1 0 0 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
color surfaceColor = mix( left, right, s ); Oi = Os; Ci = Oi * surfaceColor; } .sl A B x x) * 1 ( * B A x 1 x 1
RenderMan for Artists wanochoi.com
step(a,x) = (x<a) ? 0 : 1
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
color surfaceColor = step( 0.5, s ); Oi = Os; Ci = Oi * surfaceColor; } .sl a x 1 0
RenderMan for Artists wanochoi.com
1 - step(a,x) = (x<a) ? 1 : 0
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
color surfaceColor = 1 - step( 0.5, s ); Oi = Os; Ci = Oi * surfaceColor; } .sl a x 1 0
RenderMan for Artists wanochoi.com
step(a,x) – step(b,x) = (x<a) ? 0 : ( (x<b) ? 1 : 0 )
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
color surfaceColor = step( 0.2, s ) - step ( 0.8, s ); Oi = Os; Ci = Oi * surfaceColor; } .sl a x 1 0 b
RenderMan for Artists wanochoi.com
step() + mix()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = step( 0.5, s ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
smoothstep(a,b,x)
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = smoothstep( 0.4, 0.6, s ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
.sl
a x
1
RenderMan for Artists wanochoi.com
1-smoothstep(a,b,x)
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = 1-smoothstep( 0.4, 0.6, s ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
.sl
a x
1
RenderMan for Artists wanochoi.com
smoothstep(a,b,x); a→b : smoothstep→step
RenderMan for Artists wanochoi.com
smoothstep(a,b,x) – smoothstep(c,d,x)
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = smoothstep( 0.2, 0.3, s ) - smoothstep( 0.7, 0.8, s ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
smoothstep(a,b,x) * ( 1 – smoothstep(c,d,x) )
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = smoothstep( 0.2, 0.3, s ) * ( 1 - smoothstep( 0.7, 0.8, s ) ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
2D smoothstep()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [0.878 0.996 0.474] “right" [0.580 0.690 0.988] Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1]
WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = smoothstep( 0.2, 0.3, s ) * ( 1 - smoothstep( 0.7, 0.8, s ) ) * smoothstep( 0.2, 0.3, t ) * ( 1 - smoothstep( 0.7, 0.8, t ) ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
abs(x) = (x<0) ? (-x) : (x)
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = abs( s – 0.5 ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
abs() + smoothstep()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float distance = abs( s - 0.5 );
float ratio = 1 - smoothstep( 0.005-0.025, 0.005+0.025, distance ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
mod() + abs() + smoothstep()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float repeat = 10;
float ss = mod( s*repeat, 1 ); float tt = mod( t*repeat, 1 ); float distanceS = abs( ss - 0.5 ); float distanceT = abs( tt - 0.5 );
float ratioS = 1 - smoothstep( 0.005-0.025, 0.005+0.025, distanceS ); float ratioT = 1 - smoothstep( 0.005-0.025, 0.005+0.025, distanceT ); Oi = Os;
Ci = Oi * ( mix( left, right, ratioS) + mix( left, right, ratioT ) ); }
RenderMan for Artists wanochoi.com
sqrt() + smoothstep()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float distance = sqrt( (s-0.5)*(s-0.5) + (t-0.5)*(t-0.5) );
float ratio = 1 - smoothstep( 0.3-0.025, 0.3+0.025, distance ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
mod() + sqrt() + smoothstep()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float repeat = 10;
float ss = mod( s*repeat, 1 ); float tt = mod( t*repeat, 1 );
float distance = sqrt( (ss-0.5)*(ss-0.5) + (tt-0.5)*(tt-0.5) ); float ratio = 1 - smoothstep( 0.3-0.025, 0.3+0.025, distance ); Oi = Os;
Ci = Oi * mix( left, right, ratio ); }
RenderMan for Artists wanochoi.com
sin()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float ratio = sin(PI*s); Oi = Os;
Ci = Oi * mix( left, right, ratio); }
RenderMan for Artists wanochoi.com
sin()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float distance = abs( t - 0.5*(sin(2*PI*s)+1) );
float ratio = 1 - smoothstep( 0.01, 0.02, distance ); Oi = Os;
Ci = Oi * mix( left, right, ratio); }
RenderMan for Artists wanochoi.com
mod() + step()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float repeat = 10;
float ratio = step( 0.5, mod(s*repeat,1) ); Oi = Os;
Ci = Oi * mix( left, right, ratio); }
RenderMan for Artists wanochoi.com
mod() + step()
Display "result.tiff" "file" "rgb" Projection "perspective" "fov" 40 WorldBegin
Translate 0 0 10 Rotate 60 1 0 0
Surface "myShader" “left" [1 0 0] “right" [0 1 0]
Polygon "P" [-3 3 0 -3 -3 0 3 -3 0 3 3 0] "st" [0 1 0 0 1 0 1 1] WorldEnd
.rib
surface myShader( color left = 1, right = 0; ) {
float repeat = 10;
float ratioS = step( 0.5, mod(s*repeat,1) ); float ratioT = step( 0.5, mod(t*repeat,1) ); Oi = Os;
Ci = Oi * mix( left, right, mod(ratioS+ratioT,2) ); }
RenderMan for Artists wanochoi.com
References
• Cook, Robert L., Loren Carpenter, Edwin Catmull, The Reyes Image Rendering Architecture, SIGGRAPH 87. • Saty Raghavachary, Rendering for Beginners: Image synthesis using RenderMan, Focal Press, 2004
• Rudy Cortes, Saty Raghavachary, The RenderMan Shading Language Guide, Thomson Course Technology, 2007 • Ian Stephenson, Essential RenderMan Fast, Springer, 2003
• Anthony A. Apodaca, Larry Gritz, Advanced RenderMan: Creating CGI for Motion Pictures, Morgan Kaufmann, 1999 • Tony Apodaca and Darwyn Peachey, Writing RenderMan Shaders, Siggraph 1992 Course 21
• http://renderman.or.kr • http://www.fundza.com