由 ChildPark » 11日 2月 2005年, 12:04
這是一個Pattern類型Lchecker shader
surface Lchecker(
float srepect = 8,
trepect = 8,
Ka = 1,
Kd = 0.8;
color color1 = color (1, 0.5,0);
color color2 = color(1,1,1);
)
{
normal Nn = normalize(faceforward(N,I));
vector In = -normalize(I);
float ss = mod(srepect * s,1);
float tt = mod(trepect * t,1);
float checker1 = 1 - step(0.25 , ss) - step(0.75 , ss);
float checker2 = 1 - step(0.25 , tt) - step(0.75 , tt);
float final = checker1 - checker2;
color sum = mix(color1, color2, final);
Oi = Os;
Ci = mix(color1,color2,final);
Ci = Oi * Os * (sum * (Ka * ambient() + Kd * diffuse(Nn)));
}
這是reflection類型的shader,是在BMRT example內部提供的,我將它加入顏色。
surface reflection(
float Ka = 1,
Kd = 0.5,
Ks = 1,
Kr = 0.5,
blur = 0,
samples = 1,
roughness = 0.05;
color specularcol = 1,
col1 = (1,0.8,0),
col2 = (0,0.8,1);
)
{
normal Nf;
vector In;
vector uoffset, voffset;
color ev;
vector R, Rdir;
uniform float i, j;
Nf = faceforward(normalize(N), I);
In = normalize(I);
float final = ycomp(P);
ev = 0;
if (Kr > 0.001){
Rdir = normalize(reflect(In, Nf));
if (blur > 0){
uoffset = blur * normalize (vector(zcomp(Rdir) - ycomp(Rdir),
xcomp(Rdir) - zcomp(Rdir),
ycomp(Rdir) - xcomp(Rdir)));
voffset = Rdir ^ uoffset;
for (i = 0; i < samples; i += 1){
for (j = 0; j < samples; j += 1){
R = Rdir +
((i + float random()) / samples - 0.5) * uoffset +
((j + float random()) / samples - 0.5) * voffset;
ev += trace (P, normalize(R));
}
}
ev *= Kr / (samples * samples);
} else {
ev = Kr * trace (P, Rdir);
}
}
color sum = mix(col2, col1, final);
Oi = Os;
Ci = Os* (sum *(Ka *ambient() + Kd * diffuse(Nf)) +
specularcol * (ev + Ks*specular(Nf, -In, roughness)));
}
BMRT主要工作閱讀RenderMan 的RIB,詳情請看BMRT User Manual – release 2.6,因這渲染器是免費的所以大家可在網路上找到。
補充:以上的設置也適用於RenderMan ,如果想令BMRT的shader可在Houdini的SHOP內觀看便需要轉換 “.sl” 為 “.ds” Dialods Script。
Houdini + RenderMan + MentalRay + BMRT + Maya如能灌通它們的Data你便能在CG的空間隨意飛翔,我想擁有這種力量!: )