|
# Sample template that uses RSLFunction
slim 1 extensions Vint {
extensions power Vint {
# A template is an appearance that is used to generate functions and
# is fundamental to Slim's shader creation features. Templates are
# containers of properties.
template color pill_fresnel {
previewinfo {
shadingrate 1
objectsize 1
objectshape sphere
frame 1
}
# Parameters are used to collect all information associated
# with a single parameter of an appearance.
parameter float bias {
description "Bias"
label "Bias"
subtype slider
range {0 1}
detail varying
default 0.5
}
parameter float eta {
description "eta"
label "eta"
subtype slider
range {0 1}
detail varying
default 0.5
}
parameter float Kfr {
description "Kfr"
label "Kfr"
subtype slider
range {0 1}
detail varying
default 0.5
}
parameter color frescolor {
description "fresnelcolor"
label "Color fresnelcolor"
detail varying
default {1 1 1}
}
parameter color result {
access output
display hidden
}
# The RSLFunction is where the calculations are done.
# The order in which the parameters are declared must
# match the order in which they are described above.
RSLFunction {
void
//fresnel funtion
Vintpill_fresnel ( float bias ;
float eta ;
float kfr;
color frescolor;
output color result)
{
color C = 0;
extern point P;
extern normal N;
extern vector I;
normal Nn = normalize (N);
vector Nf = faceforward (Nn, I);
//bias function
float biasFunc(float t; float a;)
{
return pow(t, -log(a)/log(2));
}
float Kr = 1, Kt = 1;
fresnel (normalize(I), Nf, eta, Kr, Kt); //*****//
Kr = kfr*biasFunc(Kr, bias);
C = color ( Kr, Kr, Kr);
result = C * frescolor;
}
} } } }
|