1. Home
  2. Explore
  3. Computer Science
  4. Ray Tracing Basics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Ray Tracing Basics

  • 62Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Ray Tracing Introduction
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What initial resource materials were used for research into ray tracing?

Tap to flipClick to flipspace

The 'Ray Tracing in One Weekend Trilogy' and a series of blog posts titled 'Casual Shader Toy Path Tracing'.

Or swipe the card

62 cards

  1. What initial resource materials were used for research into ray tracing?

    The 'Ray Tracing in One Weekend Trilogy' and a series of blog posts titled 'Casual Shader Toy Path Tracing'.

  2. Why is a game engine used as the environment for building the ray tracer?

    For the convenience of having a scene view set up to place and move objects, and to easily compare the built-in renderer with the custom ray-traced renders.

  3. How is the camera perspective ensured to be the same for comparison between the built-in and ray-traced renders?

    Code was written to understand the camera setup, drawing a grid of points on the projection plane that updates with changes in field of view, camera movement, and rotation.

  4. How is the height of the projection plane calculated for the camera setup?

    Using the field of view (FOV) and some trigonometry.

  5. Once the height of the projection plane is calculated, how is its width determined?

    The width follows from the aspect ratio of the display.

  6. How are the directions towards points on the projection plane visualized?

    By drawing little arrows from the camera towards each point.

  7. Why is ray tracing done 'ancient Greek style' by shooting light beams out of the eyes (camera) instead of from light sources?

    In reality, most light emitted from sources would miss the eyes/camera, making that approach wildly inefficient. Shooting rays from the camera ensures only relevant light paths are considered.

  8. What component is responsible for sending camera information to a Shader, running it, and drawing the results to the screen?

    The Ray Tracing Manager script.

  9. What does a Shader's output for each pixel typically represent?

    The color of that pixel.

  10. How can a horizontal gradient from 0 to 1 be visualized using a Shader?

    By returning the x-coordinate of the current pixel.

  11. What information does the Ray structure hold?

    An origin point and a direction.

  12. How is the ray's origin point typically determined in a camera-centric ray tracer?

    The camera position, which is given to the Shader by default.

  13. How is the ray's direction calculated for each pixel?

    By calculating the position of the current pixel on the camera's projection plane using coordinates and camera information, then forming a vector from the camera origin to that point.

  14. What is the mathematical equation for a sphere centered at zero with a given radius?

    x2+y2+z2=radius2x^2 + y^2 + z^2 = \text{radius}^2x2+y2+z2=radius2

  15. How can one determine if a ray intersects a sphere?

    By starting at the ray origin, moving along the ray direction for some distance, and checking if the squared length of that vector equals the squared radius of the sphere.

  16. What does it mean if the part under the square root in the sphere intersection equation is negative?

    The equation has no real solution, meaning the ray has missed the sphere.

  17. What does it mean if the part under the square root in the sphere intersection equation is zero?

    The ray touches the sphere at just one point (it is tangent to the sphere).

  18. What does it mean if the part under the square root in the sphere intersection equation is positive?

    There are two points where the ray intersects the sphere.

  19. What information does the hit info structure store after a ray-sphere intersection test?

    Whether the ray hit something, and if so, the distance, position, and normal vector of the hit.

  20. What is a normal vector?

    If you were standing on the surface, the direction that would be 'up'. It's perpendicular to the surface at that point.

  21. How are spheres with different positions handled conceptually in the intersection code?

    The sphere is kept centered at zero, and the ray is conceptually moved away instead.

  22. What information does the Ray Tracing Material structure currently hold?

    The color of an object.

  23. What information does the Sphere structure hold for multiple spheres in a scene?

    A position, radius, and material.

  24. How does the ray_collision function identify which sphere a ray hits?

    It loops over every sphere, performs an intersection test, and keeps track of the closest hit (distance, position, normal, and material).

  25. What are the two main types of reflections when a ray of light hits a surface?

    1. Specular reflection: Light bounces off like a mirror, with the same angle going out as coming in (smooth surfaces). 2. Diffuse reflection: Incoming light scatters out in any direction (rough surfaces).
  26. How is a unique value for each pixel generated to use as a seed for pseudo-random numbers?

    By calculating a pixel index, which is a value from 0 up to the total number of pixels in the display.

  27. What was the initial, simple approach to generating random values in the Shader?

    Multiplying the pixel index seed by a large number, squaring the result, and relying on 32-bit integer overflows to create seemingly random remainders, then scaling to 0-1.

  28. How can multiple pseudo-random values be generated per pixel using the random_value function?

    By adding an inout argument for the seed, so that whatever change is made to the seed inside the function is applied to the original value, ensuring a different result each time it's called.

  29. What is the simple, initial approach to generating random directions for diffuse reflections, which equates to generating random points inside a sphere?

    Generate three random values scaled between -1 and +1 (a point inside a cube), keep generating until a point is found inside a sphere, then normalize that point to get a direction on the sphere's surface.

  30. Why is it problematic to just use the first random point generated by the simple cube-to-sphere method (without rejection sampling)?

    The points would clump up quite a lot near the corners and edges of the cube, resulting in a non-uniform distribution on the sphere's surface.

  31. What alternative approach is mentioned for generating random points uniformly over the surface of a sphere, instead of using uniform random numbers?

    Using random numbers in a normal (Gaussian) distribution.

  32. When a ray hits a surface, why is it necessary to pick a random direction within a hemisphere oriented around the normal vector of the surface?

    To simulate diffuse reflections where light scatters outwards from the surface, not back into it.

  33. How can a random direction that is 'rudely pointing outside of the desired hemisphere' be detected and fixed?

    Take the dot product between the normal vector and the random direction. If it's negative, invert the random direction.

  34. What is the purpose of the trace function?

    It takes an incoming ray from the camera and traces its path as it bounces randomly through the scene, hoping to reach a light source.

  35. How does the trace function determine the path of a ray after an intersection?

    If it hits something, the ray is moved to the point of intersection, and a random direction is picked for it to bounce off in.

  36. When does the loop inside the trace function terminate?

    Either when the maximum bounce limit is reached or when the ray misses everything and shoots off into empty space.

  37. How does ray_color keep track of how incoming light is affected by objects it interacts with?

    It starts as pure white, and whenever the ray hits something, ray_color is multiplied by the object's color (from its material).

  38. How is the total light accumulated along a ray's path initialized and updated?

    It starts out at zero. When a ray hits an object, the object's emitted light (from emission_color and strength in its material) is added to the total incoming_light, tinted by the ray_color.

  39. What are the three main steps in the core of the Shader for calculating a pixel's color?

    1. Calculate a seed for generating random numbers. 2. Create a ray looking out from the camera. 3. Trace the path of that ray through the scene to figure out the color of the pixel.
  40. What does a bounce_limit of one signify in the ray tracer?

    The ray from the camera must hit an object and then bounce directly into a light source for that pixel to be illuminated.

  41. What is the main problem encountered when only sending out a single ray per pixel?

    The image is extremely noisy.

  42. How is the noise issue addressed without increasing rays per pixel drastically for real-time performance?

    By averaging the result over multiple frames, so that the quality gets better with time.

  43. How is the random number seed modified on each frame to ensure rays bounce differently?

    By adding the current frame number to the pixel index and multiplying it by a large number.

  44. What happens if objects are moving every frame when using temporal accumulation?

    It turns into a smudgy mess.

  45. What is added to the trace function to handle rays that miss everything?

    It gathers some kind of background environment lighting using a simple function that blends between a ground color and two sky colors based on the vertical axis of the ray direction, and adds a small circle for the sun.

  46. What is the concept behind cosine weighting when calculating light strength based on the angle of incidence?

    A beam of light hitting a surface at an angle is more spread out, meaning the overall light received by any one point will be weaker and contribute less to the pixel's lighting.

  47. How is the cosine weighting light strength calculation performed in the trace function?

    The strength of the light is calculated as the cosine of the angle between the surface normal and the direction towards the light. This light_strength then multiplies the ray_color.

  48. How can the explicit light_strength calculation be removed while achieving the same visual result?

    By making a small tweak to how random bounce directions are calculated, using a cosine weighted distribution instead of a uniform distribution over the hemisphere.

  49. What is the advantage of using a cosine weighted distribution for bounce directions?

    It sends fewer rays in directions that contribute less light and consequently more rays in directions that contribute more light, giving the same result as light_strength calculation but often faster.

  50. What is the fundamental building block from which complex 3D models can be constructed?

    Triangles.

  51. What optimization is used when checking for ray-triangle intersections in a mesh?

    It quickly tests if the ray intersects the object's bounding box before looking at all the triangles within the mesh.

  52. What is the specular reflection phenomenon?

    When a very smooth surface, like a mirror, causes light to bounce off it perfectly, with the same angle going out as it had coming in.

  53. How is the specular direction for reflection calculated in the shader?

    Based on the normal vector and the incoming direction, using a built-in reflect function.

  54. How does the ray's new direction blend between diffuse and specular reflection?

    It blends from the diffuse direction to the specular direction based on the smoothness property of the material.

  55. Why do specular highlights on a red tomato appear white, even though the tomato is red?

    Fruits have a transparent protective coating. When light hits this coating, some light bounces off specularly (untinted), while some goes through to be scattered diffusely by the red interior.

  56. How is the decision made whether the current ray should bounce off an imaginary coating (specularly) or diffusely?

    By taking a specular_probability added to the material and testing if it's greater than a random value between 0 and 1.

  57. What is the primary idea behind depth of field?

    To choose a distance at which things appear in focus, with objects outside that distance appearing blurry.

  58. How is blurriness achieved for depth of field in the ray tracer for a single pixel?

    By making the multiple rays sent out per pixel diverge slightly, by randomly nudging their viewpoint.

  59. How is a random point inside a circle generated for nudging the viewpoint?

    By calculating a random angle, converting it to a point on the unit circle using sine and cosine, and then scaling it down by the square root of a random value to be somewhere inside the circle.

  60. Why is the square root of a random value used to scale down the point on the unit circle when generating a random point inside a circle?

    Without it, the random points would cluster towards the center of the circle; the square root ensures they spread out nicely.

  61. What is an additional benefit of setting the blur strength extremely low for depth of field?

    It helps to smooth out jagged edges, providing nice anti-aliasing.

  62. How is the focus at a particular distance achieved in the depth of field effect?

    Instead of randomly offsetting the viewpoint, the ray origin is randomly offset. This causes all rays to converge on a specific viewpoint, which effectively defines the focal plane. The distance of this plane can be adjusted.

Card 1 of 62
Card 1 of 62

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent