DA8. Ray Tracing¶
Statement¶
Using the information presented in this week’s Reading Assignment and the Internet, research the following topics. Describe the concept of each topic with examples and illustrations. End your discussion with one question about your researched matters.
- Ray tracing versus Ray Casting.
- Primary and secondary rays.
- Lighting, reflection, and refraction.
Answer¶
Introduction¶
Rendering is the process of generating an image from a 3D model and display it on a 2D screen, and the process is repeated for every frame. The rendering process is complex and it involves multiple steps until it reaches its goal by shading every single pixel on the canvas (Massachusetts Institute of Technology, 2020). Ray tracing, ray casting, and rasterization are the three main rendering techniques used in computer graphics. While primary rays, secondary rays, lighting, reflection, and refraction are main concepts used within the details of the rendering process.
Ray Tracing versus Ray Casting¶
Ray tracing and ray casting are closely related; both send rays from the camera to each pixel in the viewport, and collect what objects that ray hits (along with other information such as lighting) to determine the final color of the pixel. Ray-casting is regarded as a special implementation (subclass) of ray-tracing and is usually faster (Permadi, 2025).
The table below summarizes the differences between ray tracing and ray casting (Permadi, 2025):
Aspect | Ray Casting | Ray Tracing |
---|---|---|
Principle | Rays are traced in groups (E.g. send rays for each row of pixels at once) | Rays are traced individually (E.g. send rays for each pixel) |
Speed | Faster | Slower |
Flexibility | Less flexible, only suitable for specific shapes (E.g. geometric shapes) | More flexible, suitable for any shape (E.g. arbitrary shapes) |
Quality | Lower quality, less realistic images | Higher quality, more realistic images |
RT Rendering | Suitable for real-time rendering (E.g. video games) | Suitable for offline rendering (E.g. movies, animations) |
Storage | Information is stored in memory | Information is stored in memory and disk |
Question: Is there a real difference in performance between ray tracing and ray casting in the current state of technology and advancements in hardware?
Primary and Secondary Rays¶
For ray tracing/casting to work, rays are sent (released) from the camera to the scene, and these rays are categorized into primary and secondary rays. Primary rays are the rays sent from the camera to the scene, and they are used to determine the first object that the ray hits. However, primary rays may be reflected when they hit an object, producing new rays that need to be traced, and called secondary rays (Comsol, 2025).
Question: Do we follow secondary rays exactly after the primary ray, or do we register all secondary rays and start tracing them after all primary rays have been traced?
Lighting, Reflection, and Refraction¶
Lighting in computer graphics is interesting because it is computed in an opposite way to how it works in the real world. In the real world, light is emitted from a source and bounces off objects to reach the camera. In computer graphics, light is emitted from the camera and bounces off objects to reach the light source. We usually trace secondary rays to light sources to determine the color of the pixel (Rueckert, 2002).
Reflection is the process of rays bouncing off a non-transparent surface generating a new secondary ray(s). The secondary rays properties depend on the surface properties. For example, smooth surfaces will reflect rays in a single direction, while rough surfaces diffuse rays randomly (Massachusetts Institute of Technology, 2020).
Refraction is the process of rays passing through a transparent surface and changing direction a bit. There is only one refracted ray for each incident ray; however this ray is considered a primary ray because it is a continuation of the incident ray and has the same normal (Comsol, 2025).
Question: If a pixel is affected by both reflection and refraction, how do we determine the final color of the pixel?
Conclusion¶
To conclude, ray tracing and ray casting are two rendering techniques used in computer graphics. Ray casting is a special implementation of ray tracing and is faster but less flexible. Primary rays are rays sent from the camera to the scene, while secondary rays are rays produced when primary rays hit an object. Lighting, reflection, and refraction are important concepts in computer graphics that help in achieving realistic images.
References¶
- Comsol (2025). Primary and Secondary Ray Releases. Comsol.com. https://doc.comsol.com/5.6/doc/com.comsol.help.roptics/roptics_ug_modeling.5.15.html#:~:text=Primary%20rays%20are%20released%20directly,existence%20of%20any%20other%20ray.&text=Secondary%20rays%20are%20released%20when,subjected%20to%20certain%20boundary%20conditions.
- Massachusetts Institute of Technology (2020). Coordinates and Transformations. MITOpenCourseware.https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-837-computer-graphics-fall-2012/lecture-notes/.
- Permadi. (2025). Ray Casting (Game Devlopment And Game Programming Tutorial) - Page 2. Permadi.com. https://www.permadi.com/tutorial/raycast/rayc2.html
- Rueckert, D. (2002). Lecture 11 and 12: Ray tracing. Computer Graphics 1. doc.ic.ac.uk. https://www.doc.ic.ac.uk/~dfg/graphics/graphics2008/GraphicsLecture09.pdf