** Use Turbo Mode (<Shift> key + Green Flag) ** This Raytracer project shows 3 spheres. The green sphere is partly inside the blue sphere! A "Ray Tracer" traces rays from the viewer through each pixel on the screen and calculates which object it hits first in 3D space (ie. which object is closest). The pixel is coloured with the colour of that object. More advanced Ray Tracers add different types of lighting, shadows and reflections of other objects. They also include not just spheres (which have easier math) but other 3D objects. The Math for this Project --------------------------------- With pen and paper I worked out where a ray from the viewer intersected each sphere. I used a parallel projection where the viewer looks straight at all pixels on the stage (ie. looks parallel to the Z axis) to keep the math simpler. The equation of a sphere at the origin is: x^2 + y^2 + z^2 = r^2 As rays are parallel to the Z axis, a ray through (x,y) on the stage intersects the sphere at: x, y, and z = sqrt (r^2 - x^2 - y^2) Inside the project, this equation is easily adjusted for spheres not being at the origin.