CSG in Rayshade

CSG in <#500#><#1959#>rayshade<#1959#><#500#> will generally operate properly when applied to conjunction with on boxes, spheres, tori, and blobs. These primitives are by nature consistent, as they all enclose a portion of space (no hole from the ``inside'' to the ``outside''), have surface normals which point outward (they are not ``inside-out''), and do not have any extraneous surfaces.

CSG objects may also be constructed from aggregate objects. These aggregates contain whatever is listed inside, and may therefore be inconsistent. For example, an object which contains a single triangle will not produce correct results in CSG models, because the triangle does not enclose space. However, a collection of four triangles which form a pyramid does enclose space, and if the triangle normals are oriented correctly, the CSG operators should work correctly on the pyramid.

CSG objects are specified by surrounding the objects upon which to operate, as well as any associated surface-binding commands, by the operator verb on one side and the <#501#>end<#501#> keyword on the other:

<#4878#><#4878#>
<#1371#>union<#1371#> ;SPMlt;<#1372#>Object<#1372#>;SPMgt; ;SPMlt;<#1373#>Object<#1373#>;SPMgt; [;SPMlt;<#1374#>Object<#1374#>;SPMgt; ...] <#1375#>end<#1375#>
Specify a new object defined as the union of the given objects.

<#4885#><#4885#>
<#1378#>difference<#1378#> ;SPMlt;<#1379#>Object<#1379#>;SPMgt; ;SPMlt;<#1380#>Object<#1380#>;SPMgt; [;SPMlt;<#1381#>Object<#1381#>;SPMgt; ...] <#1382#>end<#1382#>
Specify a new object defined as the difference of the given objects.

<#4892#><#4892#>
<#1385#>intersect<#1385#> ;SPMlt;<#1386#>Object<#1386#>;SPMgt; ;SPMlt;<#1387#>Object<#1387#>;SPMgt; [;SPMlt;<#1388#>Object<#1388#>;SPMgt; ...] <#1389#>end<#1389#>
Specify a new object defined as the intersection of the given objects.

Note that the current implementation does not support more that two objects in a CSG list (but it is planned for a future version).