# Mojo GPU Raytracer

**URL:** <https://forum.modular.com/t/mojo-gpu-raytracer/1391>\
**Category:** Community Showcase\
**Created:** [May 7, 2025, 10:25am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391 "2025-05-07T10:25:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gonsolo](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@gonsolo](https://forum.modular.com/u/gonsolo)\
**Post date:** [May 7, 2025, 10:25am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/1 "2025-05-07T10:25:18Z")

</div>

Since a search for “raytracer” didn’t show any results and as a learning experiment, I coded a quick and dirty GPU raytracer myself.  
It’s inefficient, slow and buggy, but here it is:

> **[GitHub - gonsolo/mojo\_gpu\_raytracer](https://github.com/gonsolo/mojo_gpu_raytracer)**
>
> Contribute to gonsolo/mojo\_gpu\_raytracer development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Caroline](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/caroline/32/8_2.png) [@Caroline](https://forum.modular.com/u/Caroline)\
**Post date:** [May 7, 2025, 3:02pm UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/2 "2025-05-07T15:02:06Z")

</div>

Awesome, thank you for sharing!

---

<div class="post-metadata">

**Author:** ![gonsolo](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@gonsolo](https://forum.modular.com/u/gonsolo)\
**Post date:** [May 7, 2025, 4:52pm UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/3 "2025-05-07T16:52:03Z")

</div>

It’s a CPU and GPU raytracer now, and less buggy. 🙂

---

<div class="post-metadata">

**Author:** ![clattner](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/clattner/32/201_2.png) [@clattner](https://forum.modular.com/u/clattner)\
**Post date:** [May 8, 2025, 12:04am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/4 "2025-05-08T00:04:36Z")

</div>

Nice! Let the graphics begin!

---

<div class="post-metadata">

**Author:** ![HammadHAB](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@HammadHAB](https://forum.modular.com/u/HammadHAB)\
**Post date:** [May 8, 2025, 7:28am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/5 "2025-05-08T07:28:38Z")

</div>

Awesome! I’m hoping that someone would write something like the Cycles renderer in mojo. 😃

---

<div class="post-metadata">

**Author:** ![gonsolo](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@gonsolo](https://forum.modular.com/u/gonsolo)\
**Post date:** [May 9, 2025, 8:21am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/6 "2025-05-09T08:21:34Z")

</div>

> [@HammadHAB](#):
>
> I’m hoping that someone would write something like the Cycles renderer in mojo

Certainly doable, but:

1. Wait for C interop in Mojo. ☹
2. Start with [Embree](https://www.embree.org/) since that’s what Cycles is using.
3. Compile it yourself.
4. Re-implement the [triangle intersector](https://github.com/RenderKit/embree/blob/ffc56d50a319c5eb3f246b3c8623f054514b06e6/kernels/geometry/triangle_intersector_moeller.h#L254). Ignore everything that’s not absolutely needed (likely etc.) and add everything that is needed (Vec3v).
5. Run the [Minimal tutorial](https://github.com/RenderKit/embree/blob/master/tutorials/minimal/minimal.cpp) and make sure it works.
6. Compile [standalone Cycles](https://projects.blender.org/blender/cycles.git), make sure it uses your Embree and compare frame rates.

From there it’s just wading through the endless templates of Embree to find the functions that are actually used, and implement them one step at a time. 🙂

And finally, if you’re still not exhausted, do the [GPU thing](https://projects.blender.org/blender/cycles/src/branch/main/src/device/optix). 🤯

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [November 5, 2025, 8:22am UTC](https://forum.modular.com/t/mojo-gpu-raytracer/1391/7 "2025-11-05T08:22:26Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
