RenderMan Shading Language: Difference between revisions

Content deleted Content added
Change link to "C (programming language)"
No edit summary
Tags: Mobile edit Mobile web edit
Line 7:
An example of a surface shader that defines a metal surface is:
<source lang="c">
surface metal (float Ka = 1; float Ks = 1; float roughness = 0.1;)
{
normal Nf = faceforward (normalize(N), I);
vector V = - normalize (I);
Oi = Os;
Ci = Os * Cs * (Ka * ambient() + Ks * specular (Nf, V, roughness));
}
</source>
Line 18:
The arguments to the shaders are global parameters that are attached to objects of the model (so one metal shader can be used for different metals and so on). Shaders have no return values, but functions can be defined which take arguments and return a value. For example, the following function computes vector length using the [[dot product]] operator ".":
<source lang="c">
float length (vector v) {
return sqrt (v . v); /* . is a dot product */
}
</source>