Ken Hung
kehung@calpoly.edu
CPE 473
Constructive Solid Geometry (CSG) takes primitives such as Sphere, Box, Cone, Cylinder, Torus, etc... and applies Set operations on them to obtain more complex geometry or surfaces. My implementation includes the following:
Primitives
Set Operations
Within the context of a raytracer, implementing CSG is straightforward. The same principle described above is applied at the ray level. Each ray intersection returns an interval that represents where the ray has entered and exited a primitive. Set Operations are then applied to these intervals according to a specified order in the file (.pov). The closest t is recorded per pixel after Set operations have been applied to the intervals and the pixel is colored accordingly.
The following are examples of each Set operation between a Box and a Sphere:
UNION
INTERSECTION
DIFFERENCE
In order to handle multiple primitives, a CSG Tree is used to maintain operation ordering among primitives. It is a binary tree with primitives in the leaf nodes and Set operations in the interior nodes.
The following exemplify multiple Set operations on multiple primitives.
Other CSG Images
http://groups.csail.mit.edu/graphics/classes/6.838/F01/lectures/SmoothSurfaces/0the_s040.html
http://www.cse.ohio-state.edu/~parent/classes/681/Lectures/19.RayTracingCSG.pdf
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html
CPU bunny_jumbo_tris.pov 640x480 w/o Shadows w/o Anti-Aliasing -------------------------------------------------------------------------- real 18m34.650s user 18m32.900s sys 0m0.080s CPU bunny_jumbo_tris.pov 640x480 w/ Shadows w/o Anti-Aliasing -------------------------------------------------------------------------- real > 1 hour user ?? sys ?? CPU (BVH) bunny_jumbo_tris.pov 640x480 w/ Shadows w/o Anti-Aliasing -------------------------------------------------------------------------- real 1m27.810s user 1m25.415s sys 0m1.243s GPU (CUDA) bunny_jumbo_tris.pov 640x480 w/o Shadows w/o Anti-Aliasing -------------------------------------------------------------------------- real 1m3.030s user 0m56.188s sys 0m6.592s
Image of bunny_jumbo_tris.pov 640x480 With Shadows, No Anti-Aliasing