5.3 OBJECT MODIFIERS
----------------------
A variety of modifiers may be attached to objects. Transformations such as
translate, rotate and scale have already been discussed. Textures are in a
section of their own below. Here are three other important modifiers:
clipped_by, bounded_by and no_shadow. Although the examples below use
object statements and object identifiers, these modifiers may be used on
any type of object such as sphere, box etc.
5.3.1 CLIPPED_BY
The "clipped_by" statement is technically an object modifier but it
provides a type of CSG similar to CSG intersection. You attach a clipping
object like this:
object {
My_Thing
clipped_by{plane{y,0}}
}
Every part of the object "My_Thing" that is inside the plane is retained
while the remaining part is clipped off and discarded. In an intersection
object, the hole is closed off. With clipped_by it leaves an opening. For
example this diagram shows our object "A" being clipped_by a plane{y,0}.
* *
* *
* *
***************
Clipped_by may be used to slice off portions of any shape. In many cases it
will also result in faster rendering times than other methods of altering a
shape.
Often you will want to use the clipped_by and bounded_by options with the
same object. The following shortcut saves typing and uses less memory.
object {
My_Thing
bounded_by{box{<0,0,0>,<1,1,1>}}
clipped_by{bounded_by}
}
This tells POV-Ray to use the same box as a clip that was used as a bounds.
5.3.2 BOUNDED_BY
The calculations necessary to test if a ray hits an object can be quite
time consuming. Each ray has to be tested against every object in the
scene. POV-Ray attempts so speed up the process by building a set of
invisible boxes, called bounding slabs, which cluster the objects together.
This way a ray that travels in one part of the scene doesn't have to be
tested against objects in another far away part of the scene. When large
number objects are present the slabs are nested inside each other. POV-Ray
can use slabs on any finite object. However infinite objects such as
plane, quadric, quartic, cubic & poly cannot be automatically bound. Also
CSG objects cannot be efficiently bound by automatic methods. By attaching
a bounded_by statement to such shapes you can speed up the testing of the
shape and make it capable of using bounding slabs.
If you use bounding shapes around any complex objects you can speed up the
rendering. Bounding shapes tell the ray tracer that the object is totally
enclosed by a simple shape. When tracing rays, the ray is first tested
against the simple bounding shape. If it strikes the bounding shape, then
the ray is further tested against the more complicated object inside.
Otherwise the entire complex shape is skipped, which greatly speeds
rendering.
To use bounding shapes, simply include the following lines in the
declaration of your object:
bounded_by {
object { ... }
}
An example of a Bounding Shape:
intersection {
sphere {<0,0,0>, 2}
plane {<0,1,0>, 0}
plane {<1,0,0>, 0}
bounded_by {sphere {<0,0,0>, 2}}
}
The best bounding shape is a sphere or a box since these shapes are highly
optimized, although, any shape may be used. If the bounding shape is
itself a finite shape which responds to bounding slabs then the object
which it encloses will also be used in the slab system.
CSG shapes can benefit from bounding slabs without a bounded_by statement
however they may do so inefficiently in intersection, difference and merge.
In these three CSG types the automatic bound used covers all of the
component objects in their entirety. However the result of these
intersections may result in a smaller object. Compare the sizes of the
illustrations for union and intersection in the CSG section above. It is
possible to draw a much smaller box around the intersection of A and B than
the union of A and B yet the automatic bounds are the size of union{A B}
regardless of the kind of CSG specified.
While it is almost always a good idea to manually add a bounded_by to
intersection, difference and merge, it is often best to NOT bound a union.
If a union has no bounded_by and no clipped_by then POV-Ray can internally
split apart the components of a union and apply automatic bounding slabs to
any of its finite parts. Note that some utilities such as RAW2POV may be
able to generate bounds more efficiently than POV-Ray's current system.
However most unions you create yourself can be easily bounded by the
automatic system. For technical reasons POV-Ray cannot split a merge
object. It is probably best to hand bound a merge, especially if it is
very complex.
Note that if bounding shape is too small or positioned incorrectly, it may
clip the object in undefined ways or the object may not appear at all. To
do true clipping, use clipped_by as explained above. Often you will want to
use the clipped_by and bounded_by options with the same object. The
following shortcut saves typing and uses less memory.
object {
My_Thing
clipped_by{box{<0,0,0>,<1,1,1>}}
bounded_by{clipped_by}
}
This tells POV-Ray to use the same box as a bounds that was used as a clip.
5.3.3 NO_SHADOW
You may specify the no_shadow keyword in object and that object will not
cast a shadow. This is useful for special effects and for creating the
illusion that a light source actually is visible. This keyword was
necessary in earlier versions of POV-Ray which did not have the
"looks_like" statement. Now it is useful for creating things like laser
beams or other unreal effects.
Simply attach the keyword as follows:
object {
My_Thing
no_shadow
}