From: Lukas Jiriste Date: Tue, 26 Nov 2024 19:10:26 +0000 (+0100) Subject: Change plane light diffusion X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=25d1f45db598c331358f4da3d3c521bcf43a7cd4;p=42%2FminiRT.git Change plane light diffusion In the previous commit I noted that plane may not interact with light, if the normal has the wrong sign. This commit changes but now a plane is illuminated through itself - it diffuses light that is on the other side than the camera. This could be excused arguing that it is an infinitely thin piece so it should emit light on both sides, but I would rather it would only emit light on the side it is illuminated on. --- diff --git a/src/scene.c b/src/scene.c index 02105b5..2b112d9 100644 --- a/src/scene.c +++ b/src/scene.c @@ -286,6 +286,8 @@ t_color get_light_contribution(t_vec3 point, const t_object *object, const t_lig normal = get_object_normal(object, point); angle_multiplier = vec_scalar_mul(normal, new_ray.direction) / (vec_norm(normal) * vec_norm(new_ray.direction)); + if (object->type == PLANE) + angle_multiplier = fabs(angle_multiplier); if (angle_multiplier > 0 && (!obstruction || 1 < get_intersection_arg(&new_ray, obstruction) || get_intersection_arg(&new_ray, obstruction) < 0))