Lecture #06. Ray tracing. Camera rays

Computer graphics in Game development

Ivan Belyavtsev

30.09.2022

Recall: rasterization pipeline

Cornell box

Rasterizer vs original

Rasterizer result Original

Definitions

Shading is how surfaces are “painted” with light

Shadow is a dark area formed by occluded light source [1]

Turner Whitted demo (1979)

From: [2]

Ray tracing idea

From: [3]

Wave–particle duality of light

From: https://me.me/i/light-s-olar-system-wave-particle-duality-intesifies-5a1956376a2d4ceab14afca19bae5409

Mathematical definition of ray

\[ray(t)=\vec{origin}+t*\hat{direction}\]

\[t>0\]

Raytracing pipeline

From: [4][5]

Ray generation

Ray generation method generates primary rays (camera rays) and call Trace ray to evaluate the final color of each trace.

Pinehole camera model

From: http://commons.wikimedia.org/wiki/Image:Pinhole-camera.png

Camera ray-casting

Ray casting from position, direction, right and up vectors

[6]

Miss shader

Miss shader is called when Trace ray haven’t found any intersection

From: [4][5]

Default scene

Miss sharer is used to generate a scene without geometry. Could be pure color, sky, terrain, etc

by Morgan McGuire

Lab: 2.01 Ray generation

  1. Implement set_render_target, set_viewport, and clear_render_target methods of raytracer class
  2. Add render_target, camera, and raytracer in ray_tracing_renderer class
  3. Implement ray_generation and trace_ray method of raytracer class
  4. Implement miss_shader, image clearing, calling ray_generation, and saving in ray_tracing_renderer class

References

1.
Marschner S., Shirley P. Fundamentals of computer graphics, fourth edition. 4th ed. Natick, MA, USA: A. K. Peters, Ltd., 2016.
2.
Whitted T. An improved illumination model for shaded display. // Commun. ACM. 1980. Vol. 23, № 6. P. 343–349.
3.
McGuire M. The graphics codex. 2.14 ed. Casual Effects, 2018.
4.
Lefrançois M.-K., Gautron P. DX12 raytracing tutorial - part 2 [Electronic resource]. URL: https://developer.nvidia.com/rtx/raytracing/dxr/DX12-Raytracing-tutorial-Part-2.
5.
Parker S.G. et al. OptiX: A general purpose ray tracing engine // ACM SIGGRAPH 2010 papers. New York, NY, USA: Association for Computing Machinery, 2010.
6.
Shirley P. Ray tracing in one weekend. second. Amazon.com Services LLC, 2019. Vol. 1.