|
# 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_reflection {
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 kenv {
description "kenv"
label "kenv"
subtype slider
range {0 1}
detail varying
default 0.5
}
parameter string envname {
label "Map Name"
description "Choose an image file for mapping."
provider variable
subtype reflection
# subtypes's can be:
# environment, shadow, reflection
default "/home/cleong20/Desktop/vsfx419/testshader_prod/images/lclenv_ref.tex"
}
parameter string envspace {
label "env_coordinate"
provider variable
subtype selector
description {
#Choose a coordinate system from these
#fixed options.
}
range {
camera camera
world world
object object
shader shader
}
default object
}
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
//Reflection Function
Vintpill_reflection ( float kenv;
string envname;
string envspace;
output color result)
{
/* STEP 1 - make a copy of the surface normal one unit in length */
color envcolor = 0;
if( envname !="")
{
vector Nf = faceforward(normalize(N), I);
vector V = normalize(-I);
vector Rray = reflect ( -V, Nf);
Rray = vtransform( envspace, Rray);
envcolor = environment (envname, Rray)* kenv;
}
result = envcolor;
}
} } } }
|