An object modifier is a word that follows the arguments of an object and changes the object: it moves it, gives it a texture, says which rays can see it, or limits it. The same set of modifiers is read at the end of every shape and every CSG object. This page lists every one of them that the parser accepts, with its arguments and default, and says which objects accept it. The shapes are on Finite objects, Infinite and implicit objects and Meshes; the CSG operations are on Constructive solid geometry. The bodies of texture, pigment, normal, finish, interior and material are described on Textures and pigments, Normals and finishes and Media and interior.
How modifiers are read
- The modifiers come after the arguments of the shape and after the shape's own keywords. They can be in any order and as many times as you like. The first word that is not a modifier ends the list, and then the parser expects the closing brace of the object.
- Each modifier acts at the moment it is read. A
translatemoves the object and also the textures, bounding objects and clipping objects that the object has so far. A texture that is written after thetranslateis not moved by it. This is the reason for the order rule below. - A flag that takes an optional value (
hollow,sturm,hierarchy,no_image,no_reflection,no_radiosity,double_illuminate) is on when the word stands alone or is followed by a number above 0 (soon,true,yesand 1 are on), and off when the number is 0 or less (off,false,no).no_shadowandinversetake no value;no_shadow offis a syntax error. - If the first thing in a shape's block is the name of a declared object, the parser copies it and reads only modifiers after it (see the object wrapper).
All modifiers
| Modifier | Arguments | Default | Accepted by |
|---|---|---|---|
translate | vector | all | |
rotate | vector of angles in degrees | all | |
scale | vector or one number | all | |
matrix | 12 numbers in < > | all | |
transform | identifier or { ... } | all | |
bounded_by | { objects } or { clipped_by } | none | all |
clipped_by | { objects } or { bounded_by } | none | all |
no_shadow | none | off | all |
no_image | optional number | off | all |
no_reflection | optional number | off | all |
no_radiosity | optional number | off | all |
double_illuminate | optional number | off | all |
hollow | optional number | off | all |
inverse | none | not inverted | all (a patch gives a warning) |
sturm | optional number | off | poly, cubic, quartic, polynomial, torus, lathe, prism, sor, lemon, ovus, blob |
hierarchy | optional number | on | mesh, mesh2, blob, height_field |
open | none | closed | cylinder, cone, lemon, prism, sor, isosurface (a keyword of the shape, not of this list) |
uv_mapping | none | off | all (it has an effect on shapes that have uv coordinates) |
texture | { ... } | the default texture | all |
pigment, normal, finish | { ... } | the default texture's parts | all |
interior_texture | { ... } | none | all |
interior | { ... } | none | all |
material | { ... } | none | all |
photons | { target, refraction, reflection, collect, pass_through } | see below | all |
radiosity | { importance v } | 1.0 | all |
split_union | optional number | on | union, merge |
cutaway_textures | none | off | intersection, difference |
dtag | string | all |
Transformations
| Modifier | Syntax | Meaning |
|---|---|---|
translate | translate <x, y, z> | moves the object by the vector. A single number is repeated for all three axes: translate 2 is translate <2,2,2> |
rotate | rotate <rx, ry, rz> | turns the object about the three axes through the origin. The angles are in degrees. The rotation about x is done first, then y, then z. A single number is repeated: rotate 30 is rotate <30,30,30>, which is not a turn about one axis |
scale | scale <sx, sy, sz> or scale s | stretches the object from the origin. One number scales evenly. A factor of 0 is changed to 1 with the warning Illegal Value: Scale X by 0.0. Changed to 1.0. (one warning for each axis) |
matrix | matrix <m00, m01, m02, m10, m11, m12, m20, m21, m22, m30, m31, m32> | a 4 by 3 matrix. A point (x, y, z) becomes (x·m00 + y·m10 + z·m20 + m30, x·m01 + y·m11 + z·m21 + m31, x·m02 + y·m12 + z·m22 + m32): the first nine numbers are the three rows of the linear part and the last three are a translation. The fourth column is fixed as 0, 0, 0, 1. If a column of the 3 by 3 part is all zero, the parser sets its diagonal entry to 1 and warns Illegal matrix column: Scale by 0.0. Changed to 1.0. |
transform | transform Name or transform { ... } | applies a transformation that was declared with #declare Name = transform { ... }, or written in place |
Inside transform { ... } the following may appear, in any order and any number: translate, rotate, scale, matrix, another transform (an identifier or a block), a bare transform identifier, and inverse. They are combined in the order written, so the first one is applied first. If inverse appears anywhere in the block, the whole combined transformation is inverted at the end. The same words are read in the transformation blocks of textures and patterns.
The order rule
Transformations are applied one after the other, in the order they are written: the first written is applied to the object first. That is a different result from the reverse order, because rotation and scaling act about the origin. To rotate an object about its own centre, move it to the origin first, rotate it, and move it back. The same holds for the transformations of a transform block, and for the textures: write texture (or pigment) first and the transformations after it, so that the texture is moved with the object. A uv_mapping texture is not moved (see below).
The transformation is applied to the shape, to its bounded_by and clipped_by objects, to its textures and interior_texture, and to the media in its interior. On a CSG object it goes down to every member.
The vector function vaxis_rotate and its relatives are not modifiers; they turn a vector value in an expression (see Functions and constants).
// the order of transformations matters: the first one written is applied first
box { -0.5, 0.5 pigment { rgb <1, 0, 0> } scale <2, 1, 1> rotate z*45 translate x*3 }
box { -0.5, 0.5 pigment { rgb <0, 0, 1> } translate x*3 rotate z*45 scale <2, 1, 1> }
// a transform identifier, an inline transform block and a matrix
#declare Tilt = transform { rotate x*30 translate y }
sphere { 0, 0.5 pigment { rgb 1 } transform Tilt translate -x*3 }
sphere { 0, 0.5 pigment { rgb 1 } transform { rotate z*20 scale 1.5 translate -y*2 } translate -x*3 }
sphere { 0, 0.5 pigment { rgb <0, 1, 0> } matrix <1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0> }
// vaxis_rotate is a function, not a modifier: it turns a vector
#declare Dir = vaxis_rotate(x, y, 90);
sphere { Dir*2, 0.3 pigment { rgb <1, 1, 0> } }
vaxis_rotate.bounded_by and clipped_by
bounded_by { object ... [transformations] }
bounded_by { clipped_by }
clipped_by { object ... [transformations] }
clipped_by { bounded_by }
| Item | Meaning |
|---|---|
bounded_by { ... } | a speed-up that does not change the picture. The object is tested only for rays that hit the bounding objects. The bounding objects must enclose the whole object, or parts of it vanish. If the box of the bounding objects (the common part of their boxes, taking out inverted ones) is smaller than the box the parser computed for the object, it is used as the box of the object. A shape that is cheap to test loses its bound after parsing (Unnecessary bounding object removed., see Constructive solid geometry). |
clipped_by { ... } | cuts away the parts of the surface that lie outside the clipping objects. With several objects a point must be inside all of them. The cut is not closed: where an intersection would close a hole with a surface, a clip leaves an opening. The box of the clipping objects limits the box of the object in the same way as for bounds. For a quadric the parser computes the bounding box from the clip before the transformations, which gives a finite box for the common quadric shapes. |
| objects in the block | any objects, in any number. They may not have a texture and may not be patches (a triangle, bicubic patch, parametric, mesh without inside_vector, and CSG objects that hold one): Illegal texture or patch in clip, bound, object or potential pattern. The objects can be followed by transformations (translate, rotate, scale, transform, matrix), which move all of them together. At least one object is needed. |
bounded_by { clipped_by }, clipped_by { bounded_by } | bounded_by { clipped_by } makes the bounding objects the same list as the clipping objects written before it; clipped_by { bounded_by } does the reverse. Use it when the same objects bound and clip. Errors: Cannot link clips with previous bounds. (the object already has bounds), Cannot link bounds with previous clips. (the object already has clips), Cannot add bounds after linking bounds and clips. and Cannot add clips after linking bounds and clips. |
An object that is finite gets a bounding box from its shape; bounded_by is mostly useful for a CSG object or an object that takes long to test, such as an isosurface. Several bounded_by blocks in one object add their objects to one list.
Ray flags, hollow and inverse
| Modifier | Effect when on |
|---|---|
no_shadow | the object casts no shadow. It is useful for lamps and unreal effects, and it speeds up test renders. It takes no value. |
no_image | the camera cannot see the object, directly or through transparent or refractive objects. It still casts shadows and shows up in reflections unless no_reflection or no_shadow is set too. |
no_reflection | the object does not show up in reflections. The camera still sees it, and it casts shadows unless the other flags are set. |
no_radiosity | the object is invisible to radiosity rays, in the same way as no_image, no_reflection and no_shadow make it invisible to camera, reflection and shadow rays. |
double_illuminate | both sides of a surface are lit. Normally only the side that faces the light is. It is useful for a lamp shade or a sheet of paper. On a closed shape such as a sphere the effect shows only if the shape is partly transparent, or the camera is inside and the light outside (or the other way round). |
hollow | the inside of the object is empty: atmospheric effects (fog, atmospheric media) go on inside it. This is needed for an object that holds an interior media. Without hollow the inside counts as filled with solid material. On a CSG object the flag is passed to the members that have not set their own (see Constructive solid geometry). |
inverse | turns the inside and the outside round; the look of the surface does not change, only what the program takes as inside. It is used for CSG and for putting the camera inside an object when fog or media are in use. Written twice, it cancels. On a CSG object the object is rebuilt with the rules of De Morgan. On an object that has no inside the warning Cannot invert a patch object. is given. |
The flags are copied from a CSG object to its members, as described on the CSG page. hollow and double_illuminate are also set when they are read, so they must come after the members in a CSG block (they do, because the members come first).
sturm, hierarchy and open
| Keyword | Meaning | Accepted by |
|---|---|---|
sturm | use the Sturm root solver for the polynomial equation that is solved along each ray. It is slower and more accurate than the default solver. Use it when a surface shows holes or speckles. It is accepted only by the objects in the last column. On other objects the parser stops with Keyword 'sturm' cannot be used with this object. | poly, cubic, quartic, polynomial, torus, lathe (quadratic, cubic and Bezier splines), prism (cubic and Bezier splines), sor, lemon, ovus, blob |
hierarchy | a tree of bounding boxes (or spheres, for a blob) inside the object that speeds up the ray test. It is on by default. hierarchy off saves memory for small objects. Another object gives Keyword 'hierarchy' cannot be used with this object. | mesh, mesh2, blob, height_field |
open | removes the end faces of the shape (or the cap where an isosurface is cut by its container). It is not part of the common list but is read as part of the shape's own syntax, before the other modifiers. An object that is open has no usable inside, so it should not be used in CSG. | cylinder, cone, lemon, prism, sor, isosurface |
Textures, interior and uv_mapping
| Modifier | What the parser does |
|---|---|
texture { ... } | reads a texture and puts it on top of the textures the object already has, as a new layer (if the object has none, it becomes the object's texture). The parser stops with Cannot layer over a patterned texture. if the texture below is a pattern of textures (a texture_map and so on). |
pigment { ... }, normal { ... }, finish { ... } | change that part of the object's plain texture. If the object has no texture yet, the parser first makes one from the default texture (#default) and changes that. If the object has a patterned texture, a new plain layer is made from the default texture and changed. Several of these can follow one another. |
interior_texture { ... } | a second texture for the inside surface of the object. For an object with no inside (a patch) it is the back side of the surface. It needs an exterior texture on the same object: Interior texture requires an exterior texture. (a member of a CSG object that gets its texture from the CSG object is not enough, the member must have it itself). It is transformed like the texture. |
interior { ... } | the properties of the volume inside the object (index of refraction, media and so on); see Media and interior. Not the same as interior_texture, which is about the surface. |
material { ... } | a block that holds a texture, an interior_texture and an interior (or a material identifier). The parser merges its parts with those the object already has. |
uv_mapping | the textures of the object follow the surface's uv coordinates, not the x-y-z position. It takes no value. It must come before the first texture of the object: uv_mapping must be specified before texture. A uv-mapped texture is not moved by the transformations that come later. The uv coordinates depend on the shape: the manual lists them for each object that has them (for example the sphere, torus, box, bicubic patch, parametric, mesh, mesh2). In a CSG object, the members that take their texture from the CSG object also take its uv_mapping. |
a colour (color, colour, rgb, rgbf, rgbt, rgbft) directly in the object | read and thrown away with the warning Quick color belongs in texture. Color ignored. In a scene that declares a version before 1.5, and when the object already has a plain texture, it sets the quick colour of that texture instead. |
photons
photons { [target [density]] [refraction on|off] [reflection on|off] [collect [on|off]] [pass_through [on|off]] }
| Keyword | Value | Default | Meaning |
|---|---|---|---|
target | optional number | number 1.0; the object is not a target | makes the object a target of the photon shots. The number is the density that is stored with the object (the manual calls it a spacing multiplier). A number of 0 or less clears the target flag. |
refraction | number (required) | unset | nonzero: photons are refracted by the object; zero: they are not. The number cannot be left out. |
reflection | number (required) | unset | nonzero: photons are reflected by the object; zero: they are not. The number cannot be left out. |
collect | optional number | on | whether the object stores photons that land on it. collect off makes the object ignore them. |
pass_through | optional number | off; written alone, on | lets photons pass through the object on their way to a target. It cannot be combined with refraction and target together: the parser then switches off refraction (or pass_through) and warns Cannot use pass_through with refraction & target. |
The block is read and stored for any object; it only has an effect when the scene turns photon mapping on in global_settings. The flags of a CSG object are passed on to its members. Any other word in the block is a syntax error.
radiosity
radiosity { importance v }
importance is a number above 0 and at most 1; any other value is the error Radiosity importance must be greater than 0.0 and at most 1.0. It is the fraction of the radiosity sample rays whose first hit is this object that are fully computed, on average; the rays that are computed are weighted up to make up for the others. A small bright object can then be given a low value to avoid splotches without more rays. The default is the importance set by #default { radiosity { importance v } }, which is 1.0 unless changed. A member of a CSG object takes the importance of the CSG object unless it sets its own. The block takes no other keyword in an object.
Modifiers of CSG objects only
| Modifier | Meaning |
|---|---|
split_union [n] | whether a top-level union may be split into its members for faster rendering. On by default. The word is accepted only on a union or merge; otherwise split_union found in non-union object. |
cutaway_textures | in an intersection or difference, the cut faces keep the textures of the objects that were cut. Otherwise cutaway_textures can only be used with intersection and difference. |
Both are explained on Constructive solid geometry.
The modifiers of light_group
A light_group { ... } holds objects and light sources and has its own, shorter list of modifiers, because it does not go through the common routine:
| Modifier | Meaning |
|---|---|
translate, rotate, scale, transform, matrix | the same as above; they move the members and the lights |
global_lights [n] | whether the objects in the group are lit by the lights that are outside any group. Default off: a light group is lit by its own lights only. The word alone, or a number above 0.5, turns it on. The setting goes to the members. |
photons { ... } | the same block as for objects |
No other modifier is accepted at the end of a light group (texture and the rest are part of its members). See Lights.
Other words
dtag "text"is read and the string is thrown away; it only has an effect in a build that has the object debug helper compiled in.light_sourceas a modifier is the errorLight source must be defined using new syntax.- The words that look like modifiers but belong elsewhere:
inside_vectoris read bymeshandmesh2(see Meshes);no_bump_scaleis a keyword of textures, pigments and normals, not of objects;hf_gray_16is a leftover of the global settings that the parser reads and ignores (the setting is now a command-line or INI option);smoothandwater_levelbelong toheight_field;contained_bybelongs toisosurfaceandparametric.
Examples
// ray flags
sphere { <-3, 0, 0>, 0.5 pigment { rgb 1 } no_shadow }
sphere { <-2, 0, 0>, 0.5 pigment { rgb 1 } no_image off no_reflection on no_radiosity }
sphere { <-1, 0, 0>, 0.5 pigment { rgb 1 } hollow on double_illuminate on }
// object-level interior, material and interior_texture
sphere {
<0, 0, 0>, 0.5
material {
texture { pigment { rgbf <1, 1, 1, 0.8> } finish { reflection 0.1 } }
interior { ior 1.5 }
}
}
sphere {
<1, 0, 0>, 0.5
pigment { rgb <1, 0.5, 0> }
interior_texture { pigment { rgb <0, 0.5, 1> } }
interior { ior 1.2 }
}
// photons and radiosity importance
sphere {
<2, 0, 0>, 0.5
pigment { rgbf <1, 1, 1, 0.9> }
interior { ior 1.5 }
photons { target 1.0 refraction on reflection off collect on pass_through off }
radiosity { importance 0.5 }
}
// bounded_by and clipped_by
sphere {
<3, 0, 0>, 0.8
pigment { rgb <1, 0, 1> }
clipped_by { plane { y, 0.2 } }
}
intersection {
sphere { <3, -1, 0>, 0.8 }
sphere { <3.4, -1, 0>, 0.8 }
pigment { rgb <1, 0, 1> }
bounded_by { box { <2, -2, -1>, <4, 0, 1> } }
}
// sturm and hierarchy
torus { 0.8, 0.2 sturm rotate x*90 translate -y*2 pigment { rgb 0.7 } }
blob { threshold 0.5 sphere { 0, 1, 1 } hierarchy off translate <2, -2, 0> pigment { rgb 0.7 } }
// uv_mapping must come before the texture
sphere { <0, -2, 0>, 0.5 uv_mapping pigment { checker rgb 0, rgb 1 scale 0.25 } }
// light_group with global_lights
light_group {
light_source { <0, 4, -2>, rgb 1 }
sphere { <0, 3, 0>, 0.3 pigment { rgb 1 } }
global_lights off
}
Not described
Known, not yet covered
- Reference: the uv coordinates of each shape (which texture position each point of a sphere, torus, box and so on gets with
uv_mapping) are given in the manual and are not repeated here.
Unknown
- Reference: how the stored object density of
photons { target }is used when photons are shot was not read in the photon code; the page gives only what the parser does with the number.