
 
 / * * *   G e n e r a t e d   t h r o u g h   L u m o n i x   s h a d e r F X     b y :   A d m i n i s t r a t o r   i n   3 d s m a x   a t :   1 2 . 0 3 . 2 0 0 7   1 7 : 5 1 : 2 7     * * * /   
 
 
 
 
 
 f l o a t   d u m m y 3   :   U s e T a n g e n t ; 
 
 
 
 
 
 t e x t u r e   D i f f u s e T e x t u r e   :   C O L O R T E X T U R E 0 
 
 < 
 
 	 s t r i n g   N a m e   =   " E U P H B A R K . T G A " ; 
 
 	 s t r i n g   U I N a m e   =   " D i f f u s e T e x t u r e " ; 
 
 	 s t r i n g   R e s o u r c e T y p e   =   " 2 D " ; 
 
 > ; 
 
 
 
 s a m p l e r 2 D   D i f f u s e T e x t u r e S a m p l e r   =   s a m p l e r _ s t a t e 
 
 { 
 
 	 T e x t u r e   =   < D i f f u s e T e x t u r e > ; 
 
 	 M i n F i l t e r   =   L I N E A R ; 
 
 	 M a g F i l t e r   =   L I N E A R ; 
 
 	 M i p F i l t e r   =   L I N E A R ; 
 
 } ; 
 
   
 
 t e x t u r e   S p e c u l a r T e x t u r e   :   C O L O R T E X T U R E 1 
 
 < 
 
 	 s t r i n g   N a m e   =   " " ; 
 
 	 s t r i n g   U I N a m e   =   " S p e c u l a r T e x t u r e " ; 
 
 	 s t r i n g   R e s o u r c e T y p e   =   " 2 D " ; 
 
 > ; 
 
   
 
 s a m p l e r 2 D   S p e c u l a r T e x t u r e S a m p l e r   =   s a m p l e r _ s t a t e 
 
 { 
 
 	 T e x t u r e   =   < S p e c u l a r T e x t u r e > ; 
 
 	 M i n F i l t e r   =   L I N E A R ; 
 
 	 M a g F i l t e r   =   L I N E A R ; 
 
 	 M i p F i l t e r   =   L I N E A R ; 
 
 } ; 
 
 
 
 
 
 f l o a t   S p e c u l a r L e v e l   :   C H A N N E L V A L U E 3 
 
 < 
 
 	 s t r i n g   U I W i d g e t   =   " s l i d e r " ; 
 
 	 f l o a t   U I M i n   =   0 . 0 ; 
 
 	 f l o a t   U I M a x   =   1 0 . 0 ; 
 
 	 f l o a t   U I S t e p   =   0 . 1 ; 
 
 	 s t r i n g   U I N a m e   =   " S p e c u l a r L e v e l " ; 
 
 >   =   1 . 0 ; 
 
   
 
 f l o a t   G l o s s i n e s s L e v e l   :   C H A N N E L V A L U E 1 
 
 < 
 
 	 s t r i n g   U I W i d g e t   =   " s l i d e r " ; 
 
 	 f l o a t   U I M i n   =   0 . 0 ; 
 
 	 f l o a t   U I M a x   =   1 0 . 0 ; 
 
 	 f l o a t   U I S t e p   =   0 . 1 ; 
 
 	 s t r i n g   U I N a m e   =   " G l o s s i n e s s L e v e l " ; 
 
 >   =   1 . 0 ; 
 
   
 
 t e x t u r e   N o r m a l T e x t u r e   :   N o r m a l M a p   :   C O L O R T E X T U R E 2 
 
 < 
 
 	 s t r i n g   N a m e   =   " " ; 
 
 	 s t r i n g   U I N a m e   =   " N o r m a l T e x t u r e " ; 
 
 	 s t r i n g   R e s o u r c e T y p e   =   " 2 D " ; 
 
 > ; 
 
   
 
 s a m p l e r 2 D   N o r m a l T e x t u r e S a m p l e r   =   s a m p l e r _ s t a t e 
 
 { 
 
 	 T e x t u r e   =   < N o r m a l T e x t u r e > ; 
 
 	 M i n F i l t e r   =   L I N E A R ; 
 
 	 M a g F i l t e r   =   L I N E A R ; 
 
 	 M i p F i l t e r   =   L I N E A R ; 
 
 } ; 
 
   
 
 f l o a t   n o r m a l _ e f f e c t   :   C H A N N E L V A L U E 2 
 
 < 
 
 	 s t r i n g   U I N a m e   =   " N o r m a l   E f f e c t " ; 
 
 	 s t r i n g   U I W i d g e t   =   " s l i d e r " ; 
 
 	 f l o a t   U I M i n   =   0 . 0 ; 
 
 	 f l o a t   U I S t e p   =   0 . 0 5 ; 
 
 	 f l o a t   U I M a x   =   1 . 0 ; 
 
 >   =   0 . 5 ; 
 
 
 
 f l o a t   S e l f I l l u   :   C H A N N E L V A L U E 4 
 
 < 
 
 	 s t r i n g   U I N a m e   =   " S e l f I l l u   ( A m b i e n t L e v e l ) " ; 
 
 	 s t r i n g   U I W i d g e t   =   " s l i d e r " ; 
 
 	 f l o a t   U I M i n   =   0 . 0 ; 
 
 	 f l o a t   U I S t e p   =   0 . 0 5 ; 
 
 	 f l o a t   U I M a x   =   1 . 0 ; 
 
 >   =   0 . 5 ; 
 
 
 
 / * * * * * * * * * * * * * *   l i g h t   i n f o   * * * * * * * * * * * * * * /   
 
 
 
 f l o a t 4   l i g h t 1 P o s [ 8 ]   :   L I G H T P O S   ; 
 
 
 
 f l o a t 4   l i g h t 1 C o l o r [ 8 ]   :   L I G H T C O L O R   ; 
 
 
 
 
 
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
 
 f l o a t 4 x 4   w v p   :   W o r l d V i e w P r o j e c t i o n   <   s t r i n g   U I W i d g e t   =   " N o n e " ;   > ;     
 
 f l o a t 4 x 4   w o r l d I   :   W o r l d I n v e r s e   <   s t r i n g   U I W i d g e t   =   " N o n e " ;   > ;     
 
 f l o a t 4 x 4   w o r l d I T   :   W o r l d I n v e r s e T r a n s p o s e   <   s t r i n g   U I W i d g e t   =   " N o n e " ;   > ;     
 
 f l o a t 4 x 4   v i e w I n v   :   V i e w I n v e r s e   <   s t r i n g   U I W i d g e t   =   " N o n e " ;   > ;     
 
 f l o a t 4 x 4   w o r l d   :   W o r l d   <   s t r i n g   U I W i d g e t   =   " N o n e " ;   > ;     
 
 
 
 / /   i n p u t   f r o m   a p p l i c a t i o n   
 
 	 s t r u c t   a 2 v   {   
 
 	 f l o a t 4   p o s i t i o n 	 	 :   P O S I T I O N ;   
 
 	 f l o a t 3   t a n g e n t 	 	 :   T A N G E N T ;   
 
 	 f l o a t 3   b i n o r m a l 	 	 :   B I N O R M A L ;   
 
 	 f l o a t 3   n o r m a l 	 	 :   N O R M A L ;   
 
 
 
 	 f l o a t 2   t e x C o o r d 	 	 :   T E X C O O R D 0 ;   
 
 	 f l o a t 2   t e x C o o r d 1 	 :   T E X C O O R D 1 ; 
 
 } ;   
 
 
 
 / /   o u t p u t   t o   f r a g m e n t   p r o g r a m   
 
 s t r u c t   v 2 f   {   
 
                 f l o a t 4   p o s i t i o n         	 	 :   P O S I T I O N ;   
 
                 f l o a t 3   l i g h t V e c         	 	 :   T E X C O O R D 4 ;   
 
                 f l o a t 3   e y e V e c 	         	 :   T E X C O O R D 3 ;   
 
 	 	 f l o a t 2   T 2 	 	 	 	 :   T E X C O O R D 2 ; 
 
 	 	 f l o a t 2   t e x C o o r d 	 	 	 :   T E X C O O R D 0 ;   
 
 	 	 f l o a t 3   n o r m a l 	 	 	 :   N O R M A L ; 
 
 	 	 f l o a t 3   w o r l d T a n g e n t     	 :   T E X C O O R D 6 ;   
 
                 f l o a t 3   w o r l d B i n o r m a l   	 :   T E X C O O R D 7 ;   
 
                 f l o a t 3   w o r l d N o r m a l       	 :   T E X C O O R D 5 ; 
 
 
 
 } ;   
 
 
 
 
 
 / / D i f f u s e   a n d   S p e c u l a r   P a s s   V e r t e x   S h a d e r 
 
 v 2 f   v ( a 2 v   I n ,   u n i f o r m   f l o a t 4   l i g h t P o s i t i o n )   
 
 {   
 
 	 v 2 f   O u t   =   ( v 2 f ) 0 ;   
 
         O u t . p o s i t i o n   =   m u l ( I n . p o s i t i o n ,   w v p ) ; 	 	 	 	 / / t r a n s f o r m   v e r t   p o s i t i o n   t o   h o m o g e n e o u s   c l i p   s p a c e   
 
         / / t h i s   c o d e   w a s   a d d e d   b y   t h e   s t a n d a r d   m a t e r i a l   
 
         f l o a t 3 x 3   o b j T a n g e n t X f ; 	 	 	 	 	 	 	 	 / / b u i l d   o b j e c t   t o   t a n g e n t   s p a c e   t r a n s f o r m   m a t r i x   
 
         	 o b j T a n g e n t X f [ 0 ]   =   I n . t a n g e n t ;   
 
         	 o b j T a n g e n t X f [ 1 ]   =   - I n . b i n o r m a l ;   
 
         	 o b j T a n g e n t X f [ 2 ]   =   I n . n o r m a l ;   
 
         / / t h i s   c o d e   w a s   a d d e d   b y   t h e   s t a n d a r d   m a t e r i a l   
 
         f l o a t 4   o s L P o s   =   m u l ( l i g h t P o s i t i o n ,   w o r l d I ) ; 	 	 	 / / p u t   w o r l d   s p a c e   l i g h t   p o s i t i o n   i n   o b j e c t   s p a c e   
 
         f l o a t 3   o s L V e c   =   o s L P o s . x y z   -   I n . p o s i t i o n . x y z ; 	 	 / / o b j e c t   s p a c e   l i g h t   v e c t o r   
 
         O u t . l i g h t V e c   =   m u l ( o b j T a n g e n t X f ,   o s L V e c ) ; 	 	 	 / / t a n g e n t   s p a c e   l i g h t   v e c t o r   p a s s e d   o u t   
 
         / / t h i s   c o d e   w a s   a d d e d   b y   t h e   s t a n d a r d   m a t e r i a l   
 
         f l o a t 4   o s I P o s   =   m u l ( v i e w I n v [ 3 ] ,   w o r l d I ) ; 	 	 	 / / p u t   w o r l d   s p a c e   e y e   p o s i t i o n   i n   o b j e c t   s p a c e   
 
         f l o a t 3   o s I V e c   =   o s I P o s . x y z   -   I n . p o s i t i o n . x y z ; 	 	 / / o b j e c t   s p a c e   e y e   v e c t o r   
 
         O u t . e y e V e c   =   m u l ( o b j T a n g e n t X f ,   o s I V e c ) ; 	 	 	 	 / / t a n g e n t   s p a c e   e y e   v e c t o r   p a s s e d   o u t   
 
 
 
 	 O u t . w o r l d N o r m a l   =   m u l ( I n . n o r m a l ,   w o r l d I T ) . x y z ; 	 	 / / c o m p u t e   w o r l d   s p a c e   n o r m a l   
 
         O u t . w o r l d B i n o r m a l   =   m u l ( I n . b i n o r m a l ,   w o r l d I T ) . x y z ; 	 / / c o m p u t e   w o r l d   s p a c e   b i n o r m a l   
 
         O u t . w o r l d T a n g e n t   =   m u l ( I n . t a n g e n t ,   w o r l d I T ) . x y z ; 	 	 / / c o m p u t e   w o r l d   s p a c e   t a n g e n t 
 
 
 
 
 
 
 
 	 / / t h i s   c o d e   w a s   a d d e d   b y   t h e   t e x t u r e   m a p   N o d e   
 
         O u t . t e x C o o r d   =   I n . t e x C o o r d ; 	 	 	 	 	 	 / / p a s s   t h r o u g h   t e x t u r e   c o o r d i n a t e s   f r o m   c h a n n e l   1   
 
 	 O u t . T 2 = I n . t e x C o o r d 1 * 5 ; 
 
         r e t u r n   O u t ;   
 
 }   
 
 
 
 / / D i f f u s e   a n d   S p e c u l a r   P a s s   P i x e l   S h a d e r 
 
 f l o a t 4   f ( v 2 f   I n ,   u n i f o r m   f l o a t 4   l i g h t C o l o r )   :   C O L O R   
 
 {   
 
 	 f l o a t 3   r e t   =   f l o a t 3 ( 0 , 0 , 0 ) ;   
 
 	 f l o a t 3   V   =   n o r m a l i z e ( I n . e y e V e c ) ; 	 	 / / c r e a t i n g   t h e   e y e   v e c t o r     
 
 	 f l o a t 3   L   =   n o r m a l i z e ( I n . l i g h t V e c ) ; 	 	 / / c r e a t i n g   t h e   l i g h t   v e c t o r     
 
 
 
 	 f l o a t 3   f l a t N o r m a l   =   f l o a t 3 ( 0 . 5 f ,   0 . 5 f ,   1 . 0 f ) ; 
 
 	 f l o a t 3   N o r m a l T e x t u r e   =   t e x 2 D ( N o r m a l T e x t u r e S a m p l e r ,   I n . t e x C o o r d . x y ) ; 
 
 	 N o r m a l T e x t u r e   =   l e r p ( f l a t N o r m a l ,   N o r m a l T e x t u r e ,   n o r m a l _ e f f e c t ) ; 
 
 	 N o r m a l T e x t u r e   =   N o r m a l T e x t u r e   *   2   -   1 ; 	 	 / / e x p a n d   t o   - 1   t o   1   r a n g e   
 
 	 N o r m a l T e x t u r e . r g b   =   n o r m a l i z e ( N o r m a l T e x t u r e . r g b ) ;   
 
 
 
 	 f l o a t 4   D i f f u s e T e x t u r e   =   t e x 2 D ( D i f f u s e T e x t u r e S a m p l e r ,   I n . t e x C o o r d . x y ) ; 
 
 	 f l o a t 3   i n p u t 2   =   D i f f u s e T e x t u r e . r g b ; / / * S e l f I l l u * 2 ;   
 
 
 
 	 f l o a t 3   N n   =   n o r m a l i z e ( I n . w o r l d N o r m a l ) ;   	 	 / / i n p u t   t h e   v e c t o r s   r e q u i r e d   f o r   t a n g e n t   t o   w o r l d   s p a c e   t r a n s f o r m   
 
         f l o a t 3   T n   =   n o r m a l i z e ( I n . w o r l d T a n g e n t ) ;   
 
         f l o a t 3   B n   =   n o r m a l i z e ( I n . w o r l d B i n o r m a l ) ;   
 
 	 f l o a t 3   M a t h W o r l d X f o r m _ 1 8 4 1   = I n . n o r m a l + N n ; / / + N o r m a l T e x t u r e . r g b . y ;   / / N o r m a l v e r t e i l u n g   p l u s   N o r m a l m a p s 
 
 	 / / f l o a t 3   M a t h W o r l d X f o r m _ 1 8 4 1   =   N n   +   ( I n . n o r m a l * ( T n   +   B n ) ) ; 
 
 
 
 	 
 
 	 f l o a t 4   S p e c u l a r T e x t u r e   =   t e x 2 D ( S p e c u l a r T e x t u r e S a m p l e r ,   I n . t e x C o o r d . x y ) ; 
 
 	 f l o a t 3   i n p u t 3   =   S p e c u l a r T e x t u r e . r g b ;   
 
 
 
 
 
 	 f l o a t   i n p u t 4   =   S p e c u l a r L e v e l ;   
 
 
 
 	 f l o a t   i n p u t 5   =   G l o s s i n e s s L e v e l ;   
 
 
 
 
 
 	 	 / / n o r m a l i z e d   t h e   n o r m a l   v e c t o r   
 
 	 f l o a t 3   i n p u t 8   =   N o r m a l T e x t u r e . r g b ;   
 
 
 
 	 f l o a t 3   N   =   i n p u t 8 ; 	 	 	 	 	 	 / / u s i n g   t h e   N o r m a l   s o c k e t     
 
 	 f l o a t 3   d i f f u s e C o l o r   =   i n p u t 2 ; 	 	 	 / / u s i n g   t h e   D i f f u s e   C o l o r   s o c k e t     
 
 	 f l o a t   d i f f u s e   =   s a t u r a t e ( d o t ( N , L ) ) ; 	 	 / / c a l c u l a t e   t h e   d i f f u s e     
 
 	 d i f f u s e C o l o r   * =   l e r p ( d i f f u s e , 1 , S e l f I l l u ) ; / / * i n p u t 7 * 2 ; 	 	 	 	 / / t h e   r e s u l t i n g   d i f f u s e   c o l o r     
 
 	 	 	 	 	 	 	 	 	 	 	 / / l e r p   u m   d i e   d i f f u s e   f a r b e   i n   d e n   s c h a t t e n b e r e i c h e n   z u r  c k z u n e h m e n 
 
 
 
 	 
 
 	 r e t   + =   d i f f u s e C o l o r ; 	 	 	 	 	 / / a d d   d i f f u s e   l i g h t   t o   f i n a l   c o l o r     
 
 	 f l o a t 3   s p e c u l a r C o l o r   =   i n p u t 3 ; 	 	 	 / / u s i n g   t h e   S p e c u l a r   C o l o r   s o c k e t   
 
 	 s p e c u l a r C o l o r   * =   i n p u t 4 ; 	 	 	 / / M u l t i p l y i n g   S p e c u l a r   C o l o r   b y   t h e   S p e c u l a r   L e v e l   
 
 	 f l o a t   g l o s s i n e s s   =   i n p u t 5 ; 	 	 	 	 / / u s i n g   t h e   G l o s s i n e s s   s o c k e t     
 
 	 f l o a t 3   H   =   n o r m a l i z e ( L   +   V ) ; 	 	 	 / / C o m p u t e   t h e   h a l f   a n g l e     
 
 	 f l o a t   N d o t H   =   s a t u r a t e ( d o t ( N , H ) ) ; 	 	 / / C o m p u t e   N d o t H     
 
 	 s p e c u l a r C o l o r   * =   p o w ( N d o t H ,   g l o s s i n e s s ) ; / / R a i s e   t o   g l o s s i n e s s   p o w e r   a n d   c o m p u t e   f i n a l   s p e c u l a r   c o l o r     
 
 	 r e t   + =   s p e c u l a r C o l o r ; 	 	 	 	 	 / / a d d   s p e c u l a r   l i g h t   t o   f i n a l   c o l o r     
 
 	 r e t   * =   l i g h t C o l o r ; 	 	 	 	 	 	 / / m u l t i p l y   b y   t h e   c o l o r   o f   t h e   l i g h t   
 
 
 
 	 f l o a t 4   d o n e   =   f l o a t 4 ( r e t ,   1 ) ;   
 
 	 / / f l o a t 4   d o n e   =   f l o a t 4 ( i n p u t 9 ,   1 ) ; 
 
 	 
 
 	 r e t u r n   d o n e ;   
 
 }   
 
 
 
 t e c h n i q u e   C o m p l e t e   
 
 {     
 
 
 
 	 p a s s   l i g h t 1     
 
 	 { 	 	   
 
 	 V e r t e x S h a d e r   =   c o m p i l e   v s _ 3 _ 0   v ( l i g h t 1 P o s [ 0 ] ) ;   
 
 	 Z E n a b l e   =   t r u e ;   
 
 	 Z W r i t e E n a b l e   =   t r u e ;   
 
 	 Z F u n c   =   L e s s E q u a l ;   
 
 	 C u l l M o d e   =   c c w ;   
 
 	 A l p h a B l e n d E n a b l e   =   f a l s e ;   
 
 	 S r c B l e n d   =   O n e ;   
 
 	 A l p h a T e s t E n a b l e   =   f a l s e ;   
 
 	 A l p h a R e f   =   6 4 ;   
 
 	 A l p h a F u n c   =   G R E A T E R ;   
 
 	 D e s t B l e n d   =   O n e ;   
 
 	 P i x e l S h a d e r   =   c o m p i l e   p s _ 3 _ 0   f ( l i g h t 1 C o l o r [ 0 ] ) ;   
 
 	 }     
 
 
 
 
 
 }   
 
 