Lecture #11: Lighting and shadows

Computer graphics in Game development

Ivan Belyavtsev

21.02.2020

Recall of Phong model

\[L(\vec{P}) = Ka + \sum_{lights}{[Kd\vec{N} \cdot \vec{L} + Ks(\vec{V} \cdot \vec{R})^{Ns}]}\]

\[\vec{R} = 2(\vec{N} \cdot \vec{L})\vec{N}−\vec{L}\]

[1]

Rendering equation

\[L_o(X, \vec{\omega_o}) = L_e(X, \vec{\omega_o}) + \int_S L_i(X, \vec{\omega_o}) f_{X,\vec{n}}(\vec{\omega_i}, \vec{\omega_o}) |\vec{\omega_i} \cdot \vec{n} | d{\omega_i} \] [2]

Bidirectional reflectance distribution function

\[BRDF = f_{X,\vec{n}}(\vec{\omega_i}, \vec{\omega_o})\]

“Lighting” experiment

TODO

  • Load a scene from an OBJ file
  • Intersect all traingles
  • Add anisotropic light
  • Apply a simplified Phong model

“Lighting” experiment

Reference

From: https://github.com/djbelyak/rt-template/blob/master/references/lighting.png

“Lighting” experiment

What is the new knowledge?

  • Tinyobjlib usage
  • How to bring BRDF to our code

Shadow rays

From: https://www.researchgate.net/figure/1-This-figure-demonstrates-the-concept-of-ray-tracing-A-ray-is-cast-from-the-camera_fig1_236342499

“Shadow rays” experiment

TODO

  • Implement shadow ray casting
  • Apply shadows to the final image
  • Fix a shadow acne

“Shadow rays” experiment

Reference

From: https://github.com/djbelyak/rt-template/blob/master/references/shadow_rays.png

“Shadow rays” experiment

What is the new knowledge?

  • How to implement hard shadows
  • How to fix shadow acne

References

1. Phong B.T. Illumination for computer generated pictures // Commun. ACM. New York, NY, USA: Association for Computing Machinery, 1975. Vol. 18, № 6. Pp. 311–317.

2. McGuire M. The graphics codex. 2.14 ed. Casual Effects, 2018.