Rayshade provides a number of ways to define surfaces and to bind these surfaces to objects. The most straight-forward method of surface specification is to simply list the surface properties to be used. Alternatively, one may associate a name with a given surface. This name may subsequently be used to refer to that surface.
An object that has no surface bound to it is assigned a default surface that gives the appearance of white plastic.
The most direct way to bind a surface to a primitive is to specify the surface when the primitive is instantiated. This is accomplished by inserting a list of surface attributes or a surface name after the primitive's type keyword and before the actual primitive data.
/* * A red 'mud' colored sphere reseting on a * blue sphere. To the right is a sphere with * default surface attributes. */ surface mud ambient .03 0. 0. diffuse .7 .3 0. sphere ambient .05 .05 .1 diffuse 0 0 .7 1. 0 0 0 sphere mud 1. 0 0 2 sphere 1. 1.5 0 0
In this example, we define a red surface named ``mud''. We then instantiate a sphere, which has a diffuse blue surface bound to it. The next line instantiates a sphere with the defined ``mud'' surface bound to it. The last line instantiates a sphere with no surface bound to it; it is assigned the default surface by rayshade.
The applysurf keyword may be used to set the default surface characteristics for the aggregate object currently being defined.
/* * Mirrored ball and cylinder sitting on 'default' plane. */ surface mirror ambient .05 .05 .05 diffuse .05 .05 .05 specular .9 .9 .9 specpow 20 reflect 0.95 plane 0 0 0 0 0 1 applysurf mirror sphere 1 0 0 0 cylinder 1 3 0 0 3 0 3See example.
For convenience, the name cursurf may be used to refer to the current default surface.
The utility of bottom-up binding of surfaces lies in the fact that one may be as adamant or as noncommittal about surface binding as one sees fit when defining objects. For example, one could define a king chess piece consisting of triangles that have no surface bound to them, save for the cross on top, which has a gold-colored surface associated with it. One may then instantiate the king twice, once applying a black surface, and once applying a white surface. The result: a black king and a white king, each adorned with a golden cross.
surface white ... surface black ... surface gold ... ... define cross box x y z x y z ... defend define king triangle x y z x y z x y z ... object gold cross defend object white king translate 1. 0 0 object black king