RenderMan
RenderMan
RenderMan
CMSC 435/634
RenderMan
Setup
Project 1
Use RenderMan/Pixie (pixie.sourceforge.com) to create a C
program to model a simple scene
Grading
Follow directions
Accuracy
Creativity/Effort
RenderMan
Setup
Pixie Environment
Development Cycle
write C code
make, linking with libri → executable
run program → RIB
rndr → TIFF file
display imagefile
RenderMan
Examples
Simple Square
Minimal Program
#i n c l u d e ” r i . h ”
R t P o i n t S q u a r e [ 4 ] = { { . 5 , . 5 , . 5 } , { . 5 , − . 5 , . 5 } ,
{ − . 5 , . 5 , . 5 } , { − . 5 , − . 5 , . 5 } } ;
s t a t i c R t C o l o r C o l o r = { . 2 ,
. 4 ,
. 6 } ;
i n t main ( )
{
R i B e g i n ( ” s q u a r e . r i b ” ) ; /∗ s t a r t
t h e r e n d e r e r ∗/
R i D i s p l a y ( ” s q u a r e . t i f ” , ” f i l e ” , ” r g b ” , RI NULL ) ;
R i W o r l d B e g i n ( ) ;
R i S u r f a c e ( ” c o n s t a n t ” , RI NULL ) ;
R i C o l o r ( C o l o r ) ;
/∗ d e c l a r e
c o l o r ∗/
R i P a t c h ( RI BILINEAR , /∗ d e c l a r e t h e s q u a r e ∗/
RI P , ( R t P o i n t e r ) S q u a r e , RI NULL ) ;
RiWorldEnd ( ) ;
RiEnd ( ) ;
r e t u r n 0 ;
}
RenderMan
Examples
Simple Square
Square RIB
##RenderMan RIB−S t r u c t u r e 1 . 0
##C r e a t o r 3 D e l i g h t 2 . 1 ( Jun
5 2 0 0 4 )
##C r e a t i o n D a t e Tue Aug 31 1 8 : 3 2 : 3 8 2004
D i s p l a y
” s q u a r e . t i f ” ” f i l e ” ” r g b ”
W o r l d B e g i n
# {
S u r f a c e
” c o n s t a n t ”
C o l o r
[ 0 . 2 0 . 4 0 . 6 ]
P a t c h
” b i l i n e a r ”
”P” [ 0 . 5 0 . 5 0 . 5 0 . 5 −0.5 0 . 5
−0.5 0 . 5 0 . 5 −0.5 −0.5 0 . 5 ]
WorldEnd
# }
RenderMan
Examples
Simple Square
Results
RenderMan
Examples
Perspective & Lights
Refined Program (lights, perspective)
R i B e g i n ( ” p e r s p . r i b ” ) ; /∗ s t a r t
t h e r e n d e r e r ∗/
R i D i s p l a y ( ” p e r s p . t i f ” , ” f i l e ” , ” r g b ” , RI NULL ) ;
R i L i g h t S o u r c e ( ” d i s t a n t l i g h t ” , RI NULL ) ;
R i P r o j e c t i o n ( ” p e r s p e c t i v e ” , RI NULL ) ;
R i T r a n s l a t e ( 0 . 0 , 0 . 0 , 1 . 0 ) ;
R i R o t a t e ( 4 0 . 0 ,
−1.0 , 1 . 0 , 0 . 0 ) ;
R i W o r l d B e g i n ( ) ;
R i S u r f a c e ( ” m a t t e ” , RI NULL ) ;
R i C o l o r ( C o l o r ) ;
/∗ d e c l a r e
c o l o r ∗/
R i P a t c h ( RI BILINEAR , /∗ d e c l a r e t h e s q u a r e ∗/
RI P , ( R t P o i n t e r ) S q u a r e , RI NULL ) ;
RiWorldEnd ( ) ;
RiEnd ( ) ;
RenderMan
Examples
Perspective & Lights
Results
RenderMan
Examples
Sphere
Alternate Primitive (Sphere)
R t F l o a t
r a d i u s = 1 . 0 , zmin = −1.0 , zmax = 1 . 0 ,
t h e t a m a x =360;
...
R i W o r l d B e g i n ( ) ;
R i S u r f a c e ( ” m a t t e ” , RI NULL ) ;
R i C o l o r ( C o l o r ) ;
/∗ d e c l a r e
c o l o r ∗/
R i S p h e r e ( r a d i u s , zmin , zmax ,
t h e t a m a x , RI NULL ) ;
RiWorldEnd ( ) ;
RenderMan
Examples
Sphere
Results
RenderMan
Examples
Cube
Basic Cube Program
R i W o r l d B e g i n ( ) ;
R i S u r f a c e ( ” m a t t e ” , RI NULL ) ;
R i C o l o r ( C o l o r ) ;
/∗ d e c l a r e
c o l o r ∗/
U n i t C u b e ( ) ;
RiWorldEnd ( ) ;
RenderMan
Examples
Cube
UnitCube Function
#d e f i n e L −.5 // #d e f i n e D −.5 // #d e f i n e N −.5
#d e f i n e R . 5
// #d e f i n e U . 5
// #d e f i n e F . 5
U n i t C u b e ( ) {
s t a t i c R t P o i n t Cube [ 6 ] [ 4 ] = {
{{L , D, F } , {R , D, F } , {R , D, N} , {L , D, N} } , /∗ bottom ∗/
{{L , D, F } , {L , U , F } , {L , U , N} , {L , D, N} } , /∗ l e f t ∗/
{{R , U , N} , {L , U , N} , {L , U , F } , {R , U , F } } , /∗ t o p ∗/
{{R , U , N} , {R , U , F } , {R , D, F } , {R , D, N} } , /∗ r i g h t ∗/
{{R , D, F } , {R , U , F } , {L , U , F } , {L , D, F } } , /∗ f a r ∗/
{{L , U , N} , {R , U , N} , {R , D, N} , {L , D, N} } } ; /∗ n e a r ∗/
i n t
i ;
f o r ( i = 0 ;
i < 6 ;
i ++) {
R i P o l y g o n ( 4 , RI P , ( R t P o i n t e r ) Cube [ i ] , RI NULL ) ;
}
}
RenderMan
Examples
Cube
Results
RenderMan
Examples
Cube
Refined UnitCube
R t P o i n t S q u a r e [ 4 ] = { { . 5 , . 5 , . 5 } , { . 5 , − . 5 , . 5 } ,
{ − . 5 , . 5 , . 5 } , { − . 5 , − . 5 , . 5 } } ;
U n i t C u b e ( )
{
R i T r a n s f o r m B e g i n ( ) ;
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i R o t a t e ( 9 0 . 0 , 0 . 0 , 1 . 0 ,
0 . 0 ) ; /∗ r i g h t
f a c e ∗/
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i R o t a t e ( 9 0 . 0 , 0 . 0 , 1 . 0 ,
0 . 0 ) ; /∗ n e a r f a c e ∗/
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i R o t a t e ( 9 0 . 0 , 0 . 0 , 1 . 0 ,
0 . 0 ) ; /∗ l e f t
f a c e ∗/
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i T r a n s f o r m E n d ( ) ;
RenderMan
Examples
Cube
Refined UnitCube (cont)
R i T r a n s f o r m B e g i n ( ) ; /∗ bottom f a c e ∗/
R i R o t a t e ( 9 0 . 0 , 1 . 0 , 0 . 0 ,
0 . 0 ) ;
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i T r a n s f o r m E n d ( ) ;
R i T r a n s f o r m B e g i n ( ) ; /∗ t o p f a c e ∗/
R i R o t a t e ( − 9 0 . 0 , 1 . 0 , 0 . 0 ,
0 . 0 ) ;
R i P a t c h ( RI BILINEAR , RI P , ( R t P o i n t e r ) S q u a r e ,
RI NULL ) ;
R i T r a n s f o r m E n d ( ) ;
}
RenderMan
Examples
Cube
Results
Document Outline
- Setup
- Examples
- Simple Square
- Perspective & Lights
- Sphere
- Cube