Skip to content

Commit

Permalink
fixed black dots
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiyahar1205 committed Dec 18, 2024
1 parent e3ed7ba commit 207e017
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else
endif

# Executable file
NAME = minirt
NAME = miniRT

# Source files
SRCS = src/main.c $(wildcard src/*/*.c)
Expand Down
10 changes: 7 additions & 3 deletions src/raytracing/lighting.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: marimiyahara <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/16 00:17:06 by marimiyahar #+# #+# */
/* Updated: 2024/12/17 17:46:29 by marimiyahar ### ########.fr */
/* Updated: 2024/12/18 16:21:31 by marimiyahar ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -44,14 +44,18 @@ static bool has_shadow(t_list *objects, t_vec hit_point, t_vec light_pos)
t_vec shadow_dir;
double light_dist;
t_closest_obj find_shadow;
double relative_epsilon;
double relative_epsilon;

shadow_dir = subtract(light_pos, hit_point);
light_dist = sqrt(dot_product(shadow_dir, shadow_dir));
shadow_dir = normalize(shadow_dir);
find_shadow.min_dist = light_dist;
relative_epsilon = light_dist * 1e-3;
find_shadow.min_dist = light_dist - relative_epsilon;
find_shadow.closest_obj = NULL;
find_nearest_object(objects, hit_point, shadow_dir, &find_shadow);
if (find_shadow.closest_obj != NULL && find_shadow.min_dist < light_dist)
if (find_shadow.closest_obj != NULL && find_shadow.min_dist < light_dist
- relative_epsilon)
return (true);
return (false);
}
Expand Down

0 comments on commit 207e017

Please sign in to comment.