Created
July 26, 2020 10:31
-
-
Save omaraflak/829beec59f1ef7e1dedea4615404cc7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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