| Dim | Using Ray? | Mean runtime (s) | ————— | ————— |———| | 600x450 | Yes | 10.8 | | 600x450 | No | 48.0 | | 1200x900 | Yes | 30.16 | | 1200x900 | No | 176.7 | | 1600x1200 | Yes | 44.9 | | 1600x1200 | No | 291.2 |
Last active
June 26, 2020 19:27
-
-
Save mfitton/3ce7d617c35f5200a79c776aeaa2e9bc to your computer and use it in GitHub Desktop.
Ray Tracing Blog post using the Ray Project in python
This file contains hidden or 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
for i, x in enumerate(np.linspace(S[0], S[2], w)): | |
for j, y in enumerate(np.linspace(S[1], S[3], h)): | |
... | |
# Loop through initial and secondary rays. | |
while depth < depth_max: | |
traced = trace_ray(rayO, rayD) |
This file contains hidden or 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
@ray.remote | |
def trace_rays_with_bounces(xys): | |
results = [] | |
for (x, y) in xys: | |
# ... Snipped, same code as before ... | |
results.append(np.clip(col, 0, 1)) | |
return results |
This file contains hidden or 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
for i, x in enumerate(np.linspace(S[0], S[2], w)): | |
for j, y in enumerate(np.linspace(S[1], S[3], h)): | |
coords.append((i, j)) | |
next_task_xys.append((x, y)) | |
if len(next_task_xys) == CHUNK_SIZE: | |
results.append(trace_rays_with_bounces.remote(next_task_xys)) | |
next_task_xys = [] | |
if next_task_xys: | |
results.append(trace_rays_with_bounces.remote(next_task_xys)) | |
flat_results = chain.from_iterable(ray.get(results)) | |
for coord, result in zip(coords, flat_results): | |
i, j = coord | |
img[h - j - 1, i, :] = result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment