Ray tracing is a technique for rendering 3D graphics by simulating the path of light in a scene. It works by casting rays from the viewpoint into the scene and recursively tracing the interactions of the rays with surfaces to determine what is visible. This allows for realistic lighting effects like reflections, refractions, and shadows. The core algorithm works by casting rays for each pixel to calculate the color based on ray intersections with objects, shadows, and simulating effects like reflection and refraction through recursive ray tracing.