„Számítógépes grafika házi feladat tutorial” változatai közötti eltérés
| 970. sor: | 970. sor: | ||
<br/> <syntaxhighlight lang="c"> | <br/> <syntaxhighlight lang="c"> | ||
case Light::Directional: { | case Light::Directional: { | ||
// Lőjjünk egy sugarat a fényforrás irányába | // Lőjjünk egy sugarat a fényforrás irányába | ||
Ray shadow_checker = {inter.pos + 1e-3*light.dir, light.dir}; | // (Az irányfény iránya nálam a forrás felé mutat) | ||
Ray shadow_checker = {inter.pos + 1e-3*light.dir, light.dir}; | |||
Intersection shadow_checker_int = scene.getClosestIntersection(shadow_checker); | Intersection shadow_checker_int = scene.getClosestIntersection(shadow_checker); | ||
if(shadow_checker_int.is_valid) { | if(shadow_checker_int.is_valid) { | ||
| 984. sor: | 985. sor: | ||
Intersection shadow_checker_int = scene.getClosestIntersection(shadow_checker); | Intersection shadow_checker_int = scene.getClosestIntersection(shadow_checker); | ||
if(shadow_checker_int.is_valid && | if(shadow_checker_int.is_valid && | ||
(shadow_checker_int.pos-light.pos).length() + 1e-3 < (inter.pos-light.pos).length()) { | (shadow_checker_int.pos-light.pos).length() + 1e-3 | ||
< (inter.pos-light.pos).length()) { | |||
// Ha bármivel is ütközik, ami közelebb van a | |||
// fényhez, mint mi, akkor árnyékban vagyunk. | |||
break; | |||
} | } | ||