sl -- RenderMan Shading Language functionality
This module provides some of the functionality from the RenderMan
Shading Language. Those functions that require an actual rendering context
(surfaces, light sources, etc.) are not supported.
Most of the functions can be used just like in the Shading Language.
An exception are those functions whose return type is dependant on the
context as it's the case with random()
or noise()
.
Here, those functions have to be prepended with the return type, for example
float_random()
or point_noise()
(that is, the
cast is part of the name).
Constants:
- PI
- The same as math.pi.
Math functions:
- abs(x)
- Returns the absolute value if its argument.
This is just the builtin abs function.
- acos(a)
- Returns the arc cosine.
This function is imported from the math module.
- asin(a)
- Returns the arc sine.
This function is imported from the math module.
- atan(y [, x])
- Returns the arc tangent.
With one argument
math.atan()
is called, with two arguments
math.atan2()
is called.
- ceil(x)
- Returns the largest integer not greater than x.
This function is imported from the math module.
- clamp(x, min, max)
- Returns min if a < min, max
if a > max, otherwise a.
- color_cellnoise(p)
- Returns a color value (actually a vec3) whose value
is a (pseudo) random function of its arguments. The return value is
constant between integer lattice points.
- color_noise(p)
- Returns a color value (actually a vec3) whose value
is a (pseudo) random function of its arguments.
- color_pnoise(p, period)
- Returns a color value (actually a vec3) whose value
is a periodic (pseudo) random function of its arguments.
- color_random()
- Return a color whose componenets are a random number between 0 and 1.
The function actually returns a vec3.
- cos(a)
- Returns the cosine.
This function is imported from the math module.
- degrees(rad)
- Converts from radians to degrees.
- exp(x)
- Returns pow(e,x).
This function is imported from the math module.
- float_cellnoise(p)
- Returns a float value which is a (pseudo) random function of its arguments.
The return value is constant between integer lattice points.
This function is imported from the noise module.
- float_noise(p)
- Returns a float value which is a (pseudo) random function of its arguments.
This function is imported from the noise module.
- float_pnoise(p, period)
- Returns a float value which is a periodic (pseudo) random function of its arguments.
This function is imported from the noise module.
- float_random()
- Return a random number between 0 and 1.
This call is equivalent to
random.random()
.
- floor(x)
- Returns the smallest integer not smaller than x.
This function is imported from the math module.
- inversesqrt(x)
- Returns 1/sqrt(x).
- log(x [, base])
- Returns the natural logarithm of x (the same as math.log) or the
logarithm to the specified base.
- max(a, b, ...)
- Returns the argument with maximum value.
This is just the builtin max function.
- min(a, b, ...)
- Returns the argument with minimum value.
This is just the builtin min function.
- mix(val0, val1, t)
- For t=0 the value val0 is returned, for
t=1 the value val1 is returned. For values of
t between 0 and 1 a linearly interpolated value is returned.
- mod(a, b)
- Returns a%b.
This is just an equivalent for the %-operator.
- point_cellnoise(p)
- Returns a point (as a vec3) whose value is a (pseudo) random function
of its arguments. The return value is constant between integer lattice points.
- point_noise(p)
- Returns a point (as a vec3) whose value is a (pseudo) random function
of its arguments.
- point_pnoise(p, period)
- Returns a point (as a vec3) whose value is a periodic (pseudo) random function
of its arguments.
- point_random()
- Return a point (a vec3) whose componenets are a random number between
0 and 1.
- pow(x, y)
- Returns x^y.
This function is imported from the math module.
- radians(deg)
- Converts from degrees to radians.
- round(x)
- Returns the integer closest to x.
This is just the builtin round function.
- sign(x)
- Returns -1 with a negative argument, +1 with a positive argument,
and 0 if its argument is zero.
- sin(a)
- Returns the sine.
This function is imported from the math module.
- smoothstep(min, max, value)
- Returns 0 if value < min, 1 if
value > max, and performs a smooth Hermite
interpolation between 0 and 1 in the interval min to
max.
- spline(t, controlpoints)
- Fits a spline to the control points given and returns the value at
t which ranges from 0 to 1. At least four control points
must always be given.
- sqrt(x)
- Returns the square root.
This function is imported from the math module.
- step(min, x)
- Returns 0 if x < min, otherwise 1.
- tan(a)
- Returns the tangent.
This function is imported from the math module.
- vector_cellnoise(p)
- Returns a vector (as a vec3) whose value is a (pseudo) random function
of its arguments. The return value is constant between integer lattice points.
- vector_noise(p)
- Returns a vector (as a vec3) whose value is a (pseudo) random function
of its arguments.
- vector_pnoise(p, period)
- Returns a vector (as a vec3) whose value is a periodic (pseudo) random function
of its arguments.
Geometric functions:
- distance(p1, p2)
- Returns the distance between two points. The arguments should be
of type vec3.
- faceforward(N, I, Nref)
- Flips N so that it faces in the direction opposite to I.
Note: In contrast to the Shading Language Nref is not optional.
- length(v)
- Returns the length of a vector.
This is equivalent to calling
v.length()
.
- normalize(v)
- Returns a unit vector in the direction of v.
This is equivalent to calling
v.normalize()
.
- ptlined(p0, p1, q)
- Returns the distance between point q and the line segment
p0, p1. The arguments should be of type vec3.
- reflect(I, N)
- Returns the reflection vector given an incident direction I
and a normal vector N.
This is equivalent to calling
I.reflect(N)
.
- refract(I, N, eta)
- Returns the transmitted vector given an incident direction I,
the normal vector N and the relative index of refraction
eta.
This is equivalent to calling
I.refract(N, eta)
.
- xcomp(p)
- Return the x component of p.
This is equivalent to
p.x
.
- ycomp(p)
- Return the y component of p.
This is equivalent to
p.y
.
- zcomp(p)
- Return the z component of p.
This is equivalent to
p.z
.
- setxcomp(p, x)
- Set the x component of p.
This is equivalent to
p.x = x
.
- setycomp(p, y)
- Set the y component of p.
This is equivalent to
p.y = y
.
- setzcomp(p, z)
- Set the z component of p.
This is equivalent to
p.z = z
.
- comp(c, index)
- Get an individual color component.
This is equivalent to
c[index]
.
- setcomp(c, index, value)
- Set an individual color component.
This is equivalent to
c[index] = value
.
String functions:
- concat(str1, ..., strn)
- Returns a concatenated string.
- format(pattern, val1, val2, ..., valn)
- Returns a formatted string (similar to the C function sprintf()).
Any occurance of the character % followed by a letter is replaced by
a value. In this implementation it doesn't matter what letter you're
actually using
(in the Shading Language it would be
%f
for floats,
%p
for points,
vectors or normals, %c
for colors,
%m
for matrices and %s
for strings).
- match(pattern, subject)
- String pattern matching.
- printf(pattern, val1, val2, ..., valn)
- Prints the values of the specified variables. Any occurance of the
character
%
followed by a letter is replaced by a value. In this
implementation it doesn't matter what letter you're actually using
(in the Shading Language it would be %f
for floats,
%p
for points,
vectors or normals, %c
for colors,
%m
for matrices and %s
for strings).
Unsupported functions:
The following functions are not supported by this module:
- Du, Dv, Deriv
- filterstep
- area
- calculatenormal
- depth
- fresnel
- transform
- vtransform
- ntransform
- ambient
- diffuse
- phong
- specular
- specularbrdf
- trace
- environment
- shadow
- texture
- textureinfo
- atmosphere
- displacement
- incident
- lightsource
- opposite
- surface
- attribute
- option
- rendererinfo
Copyright © 2002 Matthias Baas
(baas@ira.uka.de)
The RenderMan (R) Interface Procedures and Protocol are:
Copyright 1988, 1989, 2000, Pixar
All Rights Reserved
RenderMan (R) is a registered trademark of Pixar