These shaders take care of selecting, creating, and remapping texture spaces, computing basis vectors, and other tasks necessary before a color or displacement can be applied. Some of these functions have a select parameter that has one of the following values:
0..63 | selects a texture vector. If this exceeds the number of defined texture spaces, default to -1 (the point in space). |
−1 | selects the 3D point in space directly, and may apply a space point transformation. |
−2 | selects the normal vector, and may apply a space vector transformation. |
−3 | selects the motion vector, and may apply a space vector transformation. |
−4 | selects the ray direction, and may apply a space vector transformation. |
−5..−9 | select a surface derivative vector, and may apply a space vector transformation. The values are ∂P⁄∂U, ∂P⁄∂V, ∂²P⁄∂U², ∂²P⁄∂V², and ∂²P⁄(∂U∂V). The object must be defined to contain derivatives. |
−10 | selects a 2D background plate coordinate with (0, 0, 0) in the lower left corner of the screen, and (1, 1, 0) just outside the upper right corner of the screen. selspace has no effect in this mode. The transformation is similar to the one in mib_lookup_background. |
−11 | selects the texture coordinate in the state, where it is typically put by a material shader when evaluating a parameter of type texture, for use by a texture shader. |
Space transformations allow transforming the vector that the projection is based on into object, world, or camera coordinates. selspace may have the following values:
0 | does not apply a transformation, using internal space. |
1 | converts the vector into object space. |
2 | converts the vector into world space. |
3 | converts the vector into camera space. |
4 | returns the current screen space coordinates in the interval [0,0 ... 1,1). |
An additional projection can be applied to the resulting vector by setting the project parameter:
0 | disables projections. |
1 | selects an UV projection if available. |
2 | selects an orthographic XY projection. |
3 | selects an orthographic XZ projection. |
4 | selects an orthographic YZ projection. |
5 | selects a spherical projection. |
6 | selects a cylindrical projection. U=0 is at +X, and V=0 is at +Y. Y is also the cylinder axis. |
7 | selects the lollipop projection, which puts the center of the texture (after texture vector normalization) at X=0.5 Z=1, and the corners at the parameter corners. On a sphere, the texture center is at the north pole and the texture corners are at the south pole, like a lollipop wrapper. |
Return a texture vector derived from orthographic projections of the 3D point in space (XY, XZ, YZ), non-orthographic projections (spherical or cylindrical); or return a numbered texture vector from the texture vector list. Optionally, this shader can base its calculations on object, camera, world, or screen space.
vector "mib_texture_vector" ( integer "select", integer "selspace", integer "vertex", integer "project")
Accepts a texture vertex and scales, rotates, translates, crops, and joins textures. The order of operations is transform first, then repeat, alternate, torus, and finally min/max crop. The result is returned (and stored in state→tex where it can be picked up by other shaders).
vector "mib_texture_remap" ( vector "input", transform "transform", vector "repeat", boolean "alt_x", boolean "alt_y", boolean "alt_z", boolean "torus_x", boolean "torus_y", boolean "torus_z", vector "min", vector "max", vector "offset")
An angle is used to rotate the surface orientation around the surface normal. An orthogonal vector pair is returned that, together with the normal which both are orthogonal to, define the rotated orientation. This is especially useful for anisotropic reflection (see below).
struct { vector "u", vector "v" } "mib_texture_rotate" ( vector "input", scalar "angle", scalar "min", scalar "max")
Given the intersection point, compute a pair of bump basis vectors, based on the projection method (as above: UV, XY, XZ, YZ, spherical, or cylindrical).
struct { vector "u", vector "v" } "mib_bump_basis" ( integer "project", integer "ntex")
Apply a texture to the normal vector by evaluating the texture at multiple points to compute U and V gradients that are multiplied with the basis vectors, combined with the original normal, normalized, and written back. Also return the normal. state→tex is left undefined.
vector "mib_bump_map" ( vector "u", vector "v", vector "coord", vector "step", scalar "factor", boolean "torus_u", boolean "torus_v", boolean "alpha", color texture "tex", boolean "clamp")
The following shader is identical to the previous, including the parameters, except that it returns a color instead of a vector. This color is not modified. This allows the shader to be used in material shader lists by prepending it to the actual material shader. In this configuration it is called first and modifies the normal vector in the state before the material shader uses it to compute illumination. At the same time, it does not in any way affect the computed result color.
vector "mib_passthrough_bump_map" ( vector "u", vector "v", vector "coord", vector "step", scalar "factor", boolean "torus_u", boolean "torus_v", boolean "alpha", color texture "tex", boolean "clamp")
See above for a description of the parameters.
This is a another approach of a bump map shader, which differs from the previous ones by modifying the state→normal and then evaluating any shading graph connected to the color input. This way the perturbed normal will be visible to the connected shader or tree. Typically, illumination shaders such as Phong should be connected to the color parameter.
The bump map will look at 3 texture samples from the texture, using the texture space 0. The differences of the 3 returned values indicate the bending of the normal. The normal will be bent in the direction of the bump_vectors if they exist, or in the direction of the derivatives otherwise. The modified normal is saved in the state before calling the evaluation of color. All shaders attached to color will then used this modified normal. The normal is set back to its original value at the end.
color "mib_bump_map2" ( scalar "factor", scalar "scale", color texture "tex", color "color" )
Copyright (©) 1986-2009 by mental images GmbH