Textures

These shaders rely on one of the texture space mapping functions above to produce the coord texture vertex, and produce a color for that vertex. Shaders that produce 2D mappings only use the x and y components of the texture vertex.

Most of these return colors. Since colors can be assigned to scalar parameters of other shaders, the shaders can be used in conjunction with blending shaders that select colors from a color spread based on a map scalar. This interacts with the fading and smoothing parameters of the texture shaders.

Image Lookup

Look up a texture image in the half-open interval [0, 1). Points outside this interval are mapped to R=G=B=A=0.

mib_texture_lookup
    color "mib_texture_lookup" (
        color texture   "tex",
        vector          "coord")
tex
is the texture image to look up.
coord
is the coordinate to look up.

This is basically a front-end to the mi_lookup_color_texture family of shader interface functions.

mib_texture_lookup2
    color "mib_texture_lookup2" (
        color texture   "tex",
        scalar          "factor")
  

An alternative to mib_texture_lookup. This uses the first set of texture coordinates in state instead of getting them as a connected parameter.

tex
is the texture image to look up.
factor
is the repetition factor of the texture.

Filtered Image Lookup

Lookup of texture image using elliptical filtering.

mib_texture_filter_lookup
    color "mib_texture_filter_lookup" (
        color texture   "tex",
        vector          "coord",
        scalar          "eccmax",
        scalar          "maxminor",
        scalar          "disc_r",
        boolean         "bilinear",
        integer         "space",
        shader          "remap")
tex
is the texture image to look up. It must be a texture image, not a texture shader; otherwise the texture is looked up unfiltered.
coord
is the central texture sampling location.
eccmax
is the maximum allowed eccentricity for the ellipse.
maxminor
is the maximum number of texture pixels for the minor radius of the ellipse.
disc_r
is used in the calculation of screen-to-texture space transformations. A default value of 0.3 is used if disc_r is zero or unspecified. For scenes with highly curved surfaces it may be useful to choose a value in the range (0.0...0.3] if aliasing artifacts appear.
bilinear
enables bilinear interpolation of texture samples if set to true. This blurs magnified areas and avoids blocky artifacts.
space
is the texture space index in the range [0...63].
remap
is a shader that is called for remapping additional texture coordinates.

The shader calls mi_texture_filter_project with the given space parameter to obtain three corresponding points in raster and texture space. These three texture coordinates are remapped by calling the specified remap shader; the actual texture coordinate for remapping is passed as the fourth argument of mi_call_shader_x (which means that the called shader must be designed to check its fourth argument). The remapping shader must use it instead of the provided texture coordinate vector in the shader parameters.

The projection transformation matrix required by the filtered texture lookup is calculated by calling the mi_texture_filter_transform shader interface function, using the three raster space and remapped texture space coordinates. The translation component in the matrix is set to coord. Note that the projection transformation is always calculated for the current raster position, but it is possible to translate the ellipse in texture space using coord. This is useful for bump mapping.

This is basically a front-end to the mi_lookup_filter_color_texture family of shader interface functions. The elliptical filter parameter bilinear is set to false in mib_texture_filter_lookup, for circle_radius the default value is used. If the projection matrix cannot be calculated properly, or the texture is a shader instead of an image, or the reflection level is not zero, nonfiltered texture lookup is used.

Checkerboard

Divide the unit cube into eight subcubes, each with a separate RGBA color. The width of the left, bottom, and front part is programmable, allowing the use of this shader for generating stripes and two- or three-dimensional checkerboards. This function is also useful for preview shaderball scenes.

mib_texture_checkerboard
    color "mib_texture_checkerboard" (
        vector          "coord",
        scalar          "xsize",
        scalar          "ysize",
        scalar          "zsize",
        color           "color000",
        color           "color001",
        color           "color010",
        color           "color011",
        color           "color100",
        color           "color101",
        color           "color110",
        color           "color111")
coord
is the coordinate to texture.
*size
specifies the fraction of the left (x), bottom (y), and front (z) half of the cube in each direction, in the range [0, 1).
color***
specifies the colors of the subcubes. The three digits stand for the XYZ coordinates: 000 is front lower left, and 100 is front lower right, and 111 is back upper right.

Polka Dot

Draw a disc with programmable diameter into the unit square, and draw a sphere with programmable diameter into the unit cube. The foreground and background colors are programmable.

mib_texture_polkadot
    color "mib_texture_polkadot" (
        vector          "coord",
        scalar          "radius",
        color           "fgcolor",
        color           "bgcolor")
  
mib_texture_polkasphere
    color "mib_texture_polkasphere" (
        vector          "coord",
        scalar          "radius",
        color           "fgcolor",
        color           "bgcolor")
coord
is the coordinate to texture.
radius
is the radius of the disc or sphere in the unit square or cube, respectively.
fgcolor
is the foreground color of the disc or sphere.
bgcolor
is the background color around the disc or sphere.

Turbulence

Create a turbulent scalar pattern in a unit cube. One, two, or all three texture vector components may be computed in polar coordinates, causing spherical mapping.

mib_texture_turbulence
    scalar "mib_texture_turbulence" (
        vector          "coord",
        scalar          "spacing",
        scalar          "strength",
        scalar          "power",
        integer         "iteration",
        integer         "polar_dim")
coord
is the coordinate to texture.
spacing
is the density of the noise in the unit cube. If it is 0, a default of 1 is used.
strength
is a weight describing the strength of the distortion. If it is 0, a default of 1 is used.
power
specifies the degree of the turbulence. If it is 0, a default of 1 is used.
iteration
sets the number of composed turbulence passes, each of which contributes a diminishing amount of turbulence as specified by the power parameter. If it is 0, a default of 2 is used. The maximum is 8.
polar_dim
specifies the number of texture vector components that should be converted to polar coordinates before computing the compound noise value. 0 creates anisotropic noise, 1 creates lines, and 2 creates cylinders.

Waves

Create cosine waves in U, V, and W directions, each with a programmable amplitude. (Frequency and offset can be controlled using a texture remapping base shader.) The result is a grayscale color, R=G=B=A, that can be remapped using a color map base shader. Its range is [o-s ... o+s] if s is the sum of the amplitudes and o is the offset.

mib_texture_wave
    color "mib_texture_wave" (
        vector          "coord",
        scalar          "amplitude_x",
        scalar          "amplitude_y",
        scalar          "amplitude_z",
        scalar          "offset")
coord
is the coordinate to texture.
amplitude_*
is a factor to multiply the generated wave with before adding it to the result. The defaults are 0 (no contribution).
offset
adds a constant value to the sum of the weighted cosines. This can be used to shift the result into the positive numbers.

Copyright (©) 1986-2009 by mental images GmbH