Skip to Main Content

What is Ray Tracing?

Ray tracing is a computational method that represents how light behaves when interacting with an object. Ray tracing is used to simulate the behavior of light when the wavelength of the light is much smaller than the object it’s interacting with.

Ray tracing tracks the path of these light rays through different optical and photonic systems and simulates how they refract, reflect, or scatter when physically interacting with different structures. There are many types of optical systems that light rays can pass through and interact with — many of which are everyday objects such as mirrors, lenses, or prisms — and all of these interactions can be simulated.

However, an important distinction needs to be made. There are two aspects to ray tracing that involve how light behaves. The most commonly referenced area of ray tracing is its use in video games. Ray tracing allows game developers to provide realistic visuals inside the game by determining how light reflects off inanimate objects, which enables the real-time development of shaders and global illumination (algorithms that add realistic lighting to 3D scenes). They also enable developers to provide rendered images of the surface textures.

 Video gaming is real-time ray tracing that’s all about speed, how the game engine provides advanced visual effects, and a high image quality — although the added computational power will lower the frame rate of a game. Ray tracing in gaming is centered around computer graphics and rendering techniques (rasterization, etc.).

On the other hand, in optics and photonics space, ray tracing is how a light source interacts with a physical object, so it considers the material properties of the system and the physical interactions that take place. In the optics and photonics space, ray tracing centers around accuracy and the behavior of light rather than acting as a visual realism tool. This article focuses on the latter for the design of optical and photonic components.

How Does Ray Tracing Work?

Ray tracing is a computational method used to model rays of light as they travel through optical systems. It is used in designing lenses, sensors, and other optical components to predict their performance based on how the light from different incident angles interacts with a structure. When light propagates through air and meets another material with a different refractive index (a property that determines how much light bends at an interface of two different mediums that have a different density), the light rays get refracted through the new medium while a portion gets reflected.

When light travels through air and encounters a material with a different refractive index(a measure of how much a material slows and bends light), it splits into two components: one part refracts (bends) as it enters the new medium, and another reflects off the surface. The degree of bending depends on the difference in refractive indices between the two materials, following Snell's law. For instance, if light moves from a low-refractive-index material (like air) into a high-refractive-index material (like glass), it bends toward the normal. Conversely, moving into a lower-index material bends it away from the normal.

Ray tracing essentially tracks the fundamental physics of light through different materials and full-scale optical components (e.g., lenses, diffraction gratings, etc.). It is a simulation-based approach that allows the paths of light to be visualized in a system. It involves looking at what the light is like near the light source and examining how those light rays change once they go through different materials and geometries. 

Overall, ray tracing is an efficient, accurate simulation approach that enables the design of high-quality optical components.

Where is Ray Tracing Used?

Ray tracing is widely used to simulate optical systems, particularly when the dimensions of the system are much larger than the wavelength of light. This size difference allows ray tracing to approximate light as rays and ignore its wave-like properties, which simplifies the calculations and makes the simulation faster and more computationally efficient.

For systems smaller than the wavelength of light, ray tracing becomes less effective because wave phenomena like diffraction and interference dominate. In such cases, a full electromagnetic field analysis (e.g., finite-difference time-domain (FDTD) or rigorous coupled-wave analysis (RCWA)) is more appropriate, as it accounts for these effects. While such methods are computationally intensive, they provide the necessary accuracy for sub-wavelength systems without requiring extremely high central processing unit (CPU) and graphics processing unit (GPU) performance for ray-based approximations.

Cell Phone

A ray tracing simulation that shows how individual light rays propagate through a cell phone lens

Ray tracing can cover every application in which light is used, from astronomy to electromagnetics, aerospace, defense, communications, medical technology, and consumer electronics. The biggest application area for ray tracing is any real-world application that involves a lens. This ranges from conventional cameras to cell phone cameras, head-up displays, telescopes, AR/VR headsets, headlamps, endoscopes, and illumination systems (medical or architectural).

Using Ray Tracing in Optic and Photonic Design

Ray tracing is used to assess the performance of optical components and improve their design to meet strict specifications. Some of the parameters that are assessed include how well the component focuses light, how much energy the light source transmits into an image (for displays), the color depth of an image, and the contrast quality of an optical component.

From a component perspective, the information gained from ray tracing can be used to optimize the design. A lot of information can be gained from ray tracing, including:

  • Lens design: Assessing how changes in lens curvature or thickness affect light propagation and optical performance
  • Manufacturing variations: Evaluating how small deviations in lens curvature or other production tolerances impact system performance
  • Maximizing space: Optimizing the housing and packaging space in optical devices
  • Changing perceptions: Seeing how the light from different angles will affect the perception of a user wearing or looking into an optical device (including how light from traffic will affect drivers looking at head-up displays)
  • Removing distortions: Identifying the source of any erroneous light sources and the effect they have
  • System alignment: Fine-tuning the position and orientation of multiple optical elements to enhance system performance
  • Image quality: Assessing what the final image quality will be in a display application

All the different potential light-altering effects and interactions between multiple lenses in complex optical systems can be assessed to look at the final performance of an optical system. Ray tracing can be used to build up this “picture” for engineers to look at before physically designing the components, which saves both time and money.

How GPUs Affect Ray Tracing Performance

In a ray tracing simulation, light trajectories are calculated across a range of geometries. In optical systems, millions, if not billions, of light rays will interact with the component being simulated. Each of these rays requires hundreds to thousands of operations to accurately calculate their path through a component, requiring a computing system with a high computational performance. 

Modern CPUs have multiple cores — up to 128 cores for the highest-end CPUs — that process each ray independently. However, GPUs (often known as graphics cards) have a different architecture with smaller but more plentiful compute units inside. Therefore, the capabilities of ray tracing can be improved by a better GPU.

The capabilities of GPUs have significantly improved since NVIDIA brought their RTX technology to market in 2018. These GPUs contain ray-tracing cores (RT cores), which are compute units solely dedicated to the optimization of ray propagation. Higher performance is achieved by having dedicated computing units for ray tracing. Ansys has been using the latest cutting-edge GPUs for years to deliver the best performance and uses NVIDIA RTX GPUs to deliver the best ray tracing simulations possible.

Software for Ray Tracing Simulations

Ansys has different software solutions available for performing ray tracing on different optical components and at different levels. The main software solutions are Ansys Zemax OpticStudio software and the Ansys Speos application.

OpticStudio software is used to look at how light rays interact with individual optical components, such as lenses, mirrors, and prisms. Once the individual optical components have been imaged, they are then put into a full systems simulation using Speos software — such as in the interior of a car — to see how light interacts with all the different components of a larger system.

Speos software can be used to investigate how a human will see the optical devices in different conditions (e.g., daytime, nighttime, cloudy days, or snowy conditions), and it also provides realistic surface renderings for all the materials in that system. For example, we can anticipate how the reflection of a chrome material into a windshield can affect the attention of the driver.

Sun ray tracing

Ansys Speos simulation of a car interior under daylight sun illumination. 100Grays. Choice of red leather and grey satin metal is demonstrated to alter driver's vision.

Night ray tracing

Ansys Speos simulation of a car interior at night. 100Grays. Driver's vision on left rear mirror is altered by the reflection of lit indicators.

Want to Learn More?

Discover how ray tracing can enhance your understanding of optical systems. Contact our technical team today for guidance on the best simulation approaches for your design.

Related Resources

Foundations of Ray Tracing Methods in Electromagnetics

Learn the latest techniques and capabilities of the shooting-and-bouncing rays (SBR) method, as manifested in HFSS SBR+.

GPU-Based Compute for Ray Tracing Makes Simulating Light More Accessible and Powerful Than Ever

Recent developments in NVIDIA GPUs have enabled Speos engineers to evolve affordable solutions that greatly accelerate ray tracing without compromising the accuracy of the results.

Take Augmented Reality and Automotive Designs to the Next Level with the Latest Ansys Zemax Updates

Learn about the new OpticStudio and OpticsBuilder capabilities that enable you to optimize your optical designs.