Skip to content

Instantly share code, notes, and snippets.

@omaraflak
Created July 26, 2020 10:31
Show Gist options
  • Save omaraflak/829beec59f1ef7e1dedea4615404cc7f to your computer and use it in GitHub Desktop.
Save omaraflak/829beec59f1ef7e1dedea4615404cc7f to your computer and use it in GitHub Desktop.
# global variable along with width, height, etc.
max_depth = 3
# everything that follows is inside the double for loop
color = np.zeros((3))
reflection = 1
for k in range(max_depth):
nearest_object, min_distance = # ...
# ...
illumination += # ...
# reflection
color += reflection * illumination
reflection *= nearest_object['reflection']
# new ray origin and direction
origin = shifted_point
direction = reflected(direction, normal_to_surface)
image[i, j] = np.clip(color, 0, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment