Sunday, April 26, 2009

ST COLORATION





surface PacMan_test_2(float Kd = 1,
Ka = 1,
LeftEyeLeftEdge = .1,
LeftEyeRightEdge = 1,
RightEyeLeftEdge = 1.4,
RightEyeRightEdge = 1.6;
color Pink =(1,0,.4);

)
{
color surfcolor = (.5,.5,.5),
pink= Pink;
float LEyeLEdge = LeftEyeLeftEdge,
LEyeREdge = LeftEyeRightEdge,
REyeLEdge = RightEyeLeftEdge,
REyeREdge = RightEyeRightEdge;


/*1st line*/
if(t >= 0.3 && t <= .4 && s >= .8 && s <= 1.2 ) surfcolor = color pink; /*2nd line*/ if(t >= 0.4 && t <= .5 && s >= .6 && s <= 1.4 ) surfcolor = color pink; /*3rd line*/ if(t >= 0.5 && t <= .6 && s >= .5 && s <= 1.5 ) surfcolor = color pink; /*4-6 line*/ if(t >= 0.6 && t <= .7 && s >= .4 && s <= 1.6 ) surfcolor = color pink; if(t >= 0.7 && t <= .8 && s >= .4 && s <= 1.6 ) surfcolor = color pink; if(t >= .8 && t <= .9 && s >= .4 && s <= 1.6 ) surfcolor = color pink; /***4 patch***/ if(t >= 0.6 && t <= .7 && s >= .7 && s <= .9 ) surfcolor = color(1,1,1); if(t >= 0.6 && t <= .7 && s >= 1.3 && s <= 1.5 ) surfcolor = color(1,1,1); /***5 patch***/ if(t >= 0.7 && t <= .8 && s >= .6 && s <= 1 ) surfcolor = color(1,1,1); if(t >= 0.7 && t <= .8 && s >= 1.2 && s <= 1.6 ) surfcolor = color(1,1,1); /***6 patch***/ if(t >= 0.8 && t <= .9 && s >= .6 && s <= .8 ) surfcolor = color(1,1,1); if(t >= 0.8 && t <= .9 && s >= .8 && s <= 1 ) surfcolor = color(0,0,1); if(t >= 0.8 && t <= .9 && s >= 1.2 && s <= 1.4 ) surfcolor = color(1,1,1); if(t >= 0.8 && t <= .9 && s >= REyeLEdge && s <= REyeREdge ) surfcolor = color(0,0,1); /*7-12 line*/ if(t >= .9 && t <= 1 && s >= .3 && s <= 1.7 ) surfcolor = color pink; if(t >= 1 && t <= 1.1 && s >= .3 && s <= 1.7 ) surfcolor = color pink; if(t >= 1.1 && t <= 1.2 && s >= .3 && s <= 1.7 ) surfcolor = color pink; if(t >= 1.2 && t <= 1.3 && s >= .3 && s <= 1.7 ) surfcolor = color pink; if(t >= 1.3 && t <= 1.4 && s >= .3 && s <= 1.7 ) surfcolor = color pink; if(t >= 1.4 && t <= 1.5 && s >= .3 && s <= 1.7 ) surfcolor = color pink; /***7 patch***/ if(t >= .9 && t <= 1 && s >= .6 && s <= .8 ) surfcolor = color(1,1,1); if(t >= .9 && t <= 1 && s >= .8 && s <= 1 ) surfcolor = color(0,0,1); if(t >= .9 && t <= 1 && s >= 1.2 && s <= 1.4 ) surfcolor = color(1,1,1); if(t >= .9 && t <= 1 && s >= 1.4 && s <= 1.6 ) surfcolor = color(0,0,1);

surface diagonal(float Kd = 1)

{
color surfcolor = (.5,.5,.5);


if (s >= 1-t)

{
surfcolor = color(0,0,1);

}//end if

Oi = Os;

Ci = Oi * Cs * surfcolor;
}






surface quadrant(float Kd = 1)

{
color surfcolor = (.5,.5,.5);


if ( (t * t) + (s * s) < surfcolor =" color(0,0,1);" oi =" Os;" ci =" Oi" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIrRTKQcf0BfLOaIFgtHi9AXtJI1wdScr4q17vAyPhMo39LI_nvZi1KgALTktYeTiUqNJo4OBmjH9mBblj6yIMOEYZ8-9rjkLW633cztzD8mVyHpqHJQjbmoqBqy1jnanFF7uLuZqAQxA/s1600-h/cross.jpg">


surface diagonal(float Kd = 1)

{
color surfcolor = (.5,.5,.5);


if ((t > 0.25 && t <> 0.25 && s < surfcolor =" color(0,0,1);" oi =" Os;" ci =" Oi">

Friday, April 24, 2009

LOD




This is the final animation of my cat.



Render with costume lights.

/* Copyrighted Pixar 1989 */
/* From the RenderMan Companion p.339 */
/* Listing 16.7 Distant light source shader */

/*
* pointlight(): provide a ligh with position but no orientation
*/
light
pointlight (

float intensity = 25;
color lightcolor = (0,0,1);
point from = point "camera" (0,0,0) ) /* light position */
{
illuminate (from)
Cl = intensity * lightcolor / (L . L);
}



Because of the poly count (440's) I only able to create short animation.



LOD rib file

AttributeBegin
Detail [-0.5 0.5 -0.5 0.5 -0.5 0.5]

Color 0 1 0
DetailRange [ 1 1 25 100]
ReadArchive "H:/My Documents/vsfx319/ribs/Cat_Low_Res.rib"

Color 1 0 0
DetailRange [25 100 250 500]
ReadArchive "H:/My Documents/vsfx319/ribs/Cat_Medium_Res.rib"

Color 0 0 1
DetailRange [250 500 1000 1000]
ReadArchive "H:/My Documents/vsfx319/ribs/Cat_High_Res.rib"
AttributeEnd

Opacity 0 0 0

Sunday, April 12, 2009

DOF


Playing with magnitude, disp ferq in s and t.



Object feel small.



Object feel huge.



Final composition.




Light Shader:


/* From the RenderMan Companion p.339 */

light
pointlight (
float intensity = 25;
color lightcolor = 1;
point from = point "camera" (0,0,0) )

illuminate (from)
Cl = intensity * lightcolor / (L . L);
}


Displacement Shader:

/*bubbly.sl written a while ago by Ivan DeWolf*/
/*modified by ME 04/11/09*/

displacement
IDbubbly(
float mult = 4,/*multiple bubbles per unit*/
Nzscale = 0,/*scale of the noise ramndomize the location of bubbles*/
Kd = -.2,/*coefficient of displacement*/
bubsize = .25,/*radius of the bubbles*/
Km = 0.05,/*Mangnitude*/
sFreq = 25, /*Displace Freq in s*/
tFreq = 25 /*Displace Freq in t*/
)
{
normal Nn = normalize(N);
float myDisp = sin(s*sFreq*PI) * sin(t*tFreq*PI);
float a,b,c,bub;
float dist, shortest=10000;
point Po = transform("object",P)*mult;


/*true cell center, surrounding cell centers, noised cell center*/
point trucell, surrcell, nzcell;
vector offset;

setxcomp(trucell,floor(xcomp(Po))+.5);
setycomp(trucell,floor(ycomp(Po))+.5);
setzcomp(trucell,floor(zcomp(Po))+.5);

/*what is the shortest distance to a noised cell center*/
for(a = -1; a<= 1; a+=1){ for(b = -1; b<=1; b += 1){ for(c = -1; c<=1; c += 1){ offset = vector(a,b,c); surrcell = trucell+offset; nzcell = surrcell + ((vector cellnoise(surrcell)-.5)*Nzscale); dist = distance(Po,nzcell); if(dist }
}
}
/*where it all happens*/
bub = clamp(shortest,0,bubsize)/bubsize;
P+= Nn*(pow(bub,2)-1) + (myDisp*Kd*Km);
N = calculatenormal(P);

}

Surface Shader 1:

surface
glow2(
float Ks = 1.0,
Ka = 0.8,
Kd = 0.8,
roughness = 0.1;
color myColor = 1;
color specularcolor = 1)
{
normal n = faceforward(normalize(N), I);
vector i = -normalize(I);

float d = n.i;
color y = myColor * 2;
color l = ambient() + diffuse(n);

Oi = 0.8*d;
Ci = Oi*mix(l, y, d);
}


Surface Shader 2:

/*AUTHOR: written by Larry Gritz*/
/*modified by ME 04/11/09*/

#define boxstep(a,b,x) (clamp(((x)-(a))/((b)-(a)),0,1))
#define MINFILTERWIDTH 1.0e-7

surface
LGWallpaper2Stripe (
float Ka = 0.5, /*ambient coefficient*/
Kd = 0.75, /*coefficient of diffuse reflection*/
Ks = 0.25; /*coefficient of specular reflection*/
float roughness = 0.1; /*size of specular highlite*/
color specularcolor = 1; /*specular*/
color stripecolor = color "rgb" (1,0.5,0.5);/*color of background and stripes*/
float stripewidth = 0.25; /*width of stripes, in s coordinates*/
float stripespacing = 0.5; /*dist between sets of stripes, in s coordinates*/
)
{
point Nf;
color Ct;
float stripe, ss;
float swidth;
float W = stripewidth/stripespacing;

/* For antialiasing */
swidth = max (abs(Du(s)*du) + abs(Dv(s)*dv), MINFILTERWIDTH) / stripespacing;

ss = mod (s, stripespacing) / stripespacing - 0.5;

if (swidth >= 1)
stripe = 1 - 20*W;
else stripe = clamp (boxstep(W-swidth,W,ss), max(1-W/swidth,0), 1)
- clamp (boxstep(W+stripewidth,W+stripewidth+swidth,ss), 0, 2*W/swidth)
+ clamp (boxstep(W-swidth+4*stripewidth,W+4*stripewidth,ss), max(1-W/swidth,0), 1)
- clamp (boxstep(W+5*stripewidth,W+5*stripewidth+swidth,ss), 0, 2*W/swidth);

Ct = mix (Cs, stripecolor, stripe);

/* compute shading normal */
Nf = faceforward (normalize(N),I);

/* diffuse reflection model */
Oi = Os;
Ci = Os * ( Ct * (Ka*ambient() + Kd*diffuse(Nf)) +
specularcolor * Ks*specular(Nf,-normalize(I),roughness));
}




Monday, April 6, 2009

Shader 101

This is the final image of my external HD from renderman using
basic shader that was created in cutter and later imported to Maya.


This is the wire frame image from Maya.



I use 3 point lighting to lit the scene. I apply different colors and intensity.



I was doing a little bit of research on glowing shader. I try to tweak the original shader hoping to get the color is changing. Apparently, it does work but it seems the color on the object is changing now. Anyway here's my working .sl file.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
/*Original Shader written by Micah Taylor*/

/*Shader tweak by Christian Tjahjono*/

surface
bulb ( float Ks = 1,
Ka = 0.8,
Kd = 0.8,
Ksilh = 0,
roughness = .1,
silhrough = 0.55;

color specularcolor = (0,0,0) )

{
/*surface normal one unit in length*/

normal n = faceforward(normalize(N), I);
vector i = -normalize(I);

/*calculation of the lighting components*/

float d = n.i;
color y = color(1,1.8,7);
color l = ambient() + diffuse(n);

/*calculation of the apparent surface color*/

Oi = 0.3*d;
Ci = Oi*mix(l, y, d);
}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


New glowing.sl :

/*Glowing Shader*/


surface glow

(
float Ks = 1.0,
Ka = 0.8,
Kd = 0.8,
roughness = 0.1;
color myColor = 1;
color specularcolor = 1)

{

/* Construct a forward facing surface normal */

normal n = faceforward(normalize(N), I);
vector i = -normalize(I);

/* Calculation for ambient diffuse and color */

float d = n.i;
color y = myColor * 2;
color l = ambient() + diffuse(n);

/* Calculation for the surface color */

Oi = 0.8*d;
Ci = Oi*mix(l, y, d);

}

A test render for the glowing shader .