Skip to content

Instantly share code, notes, and snippets.

@omaraflak
Last active July 25, 2020 08:16
Show Gist options
  • Save omaraflak/bfaa3dcc2224c17f50ac4f7524323444 to your computer and use it in GitHub Desktop.
Save omaraflak/bfaa3dcc2224c17f50ac4f7524323444 to your computer and use it in GitHub Desktop.
# ...
intersection = origin + min_distance * direction
normal_to_surface = normalize(intersection - nearest_object['center'])
shifted_point = intersection + 1e-5 * normal_to_surface
intersection_to_light = normalize(light['position'] - shifted_point)
_, min_distance = nearest_intersected_object(objects, shifted_point, intersection_to_light)
intersection_to_light_distance = np.linalg.norm(light['position'] - intersection)
is_shadowed = min_distance < intersection_to_light_distance
if is_shadowed:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment