Lecture 06: Ray tracing. Camera rays

Computer graphics in Game development

Ivan Belyavtsev

04.02.2022

Recall: rasterization pipeline

Cornell box

Rasterizer vs original

Rasterizer result Original

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\]

Ray tracing idea

From: [1]

Turner Whitted demo (1979)

From: [2]

Raytracing pipeline

From: [3][4]

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

[5]

Miss shader

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

From: [3][4]

Default scene

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

by Morgan McGuire

Lab: 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.
McGuire M. The graphics codex. 2.14 ed. Casual Effects, 2018.
2.
Whitted T. An improved illumination model for shaded display. // Commun. ACM. 1980. Vol. 23, № 6. P. 343–349.
3.
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.
4.
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.
5.
Shirley P. Ray tracing in one weekend. second. Amazon.com Services LLC, 2019. Vol. 1.
// reveal.js plugins