DEV Community

Kareem Al-Farsi
Kareem Al-Farsi

Posted on

Building Photon: A Hybrid Ray Tracer That Builds for Windows, Linux, and macOS

Repository: Photon on GitHub

Photon is a C-based adaptive hybrid ray tracer built to explore real-time rendering techniques without locking the project to one platform. The goal was simple: make a renderer that can grow into something serious, while still being practical to build, test, and ship across Windows, Linux, and macOS.

What Photon is

Photon is a modular ray tracing engine written in C17. It combines several rendering ideas into one pipeline:

  • BVH-based ray traversal
  • hybrid raster + ray tracing structure
  • denoising passes
  • probe-based indirect lighting
  • adaptive ray budgeting
  • build-time shader compilation support

The project is designed to run in a stub mode when full GPU dependencies are missing, which makes it easier to develop and test even on machines without a full Vulkan setup.

Why I built it this way

I wanted a renderer that was more than a demo or a single-file experiment. Photon is organized like an actual engine:

  • include/ holds the core types and API
  • src/ contains the implementation
  • shaders/ contains the compute and graphics shaders
  • .github/workflows/ handles CI and releases

That structure makes it easier to extend later, whether that means better materials, real Vulkan integration, texture loading, or more advanced global illumination.

What makes it different

A few things stand out in Photon:

1. Adaptive rendering

Instead of firing a fixed amount of rays every frame, Photon uses a budget system that can adjust quality depending on performance needs.

2. Hybrid pipeline

The renderer is built to combine rasterization and ray tracing ideas instead of relying on one approach only. That gives more flexibility for future features.

3. Denoising

Rendering noisy paths is normal in ray tracing, so Photon includes denoise stages like temporal and spatial filtering to make the output more stable.

4. Cross-platform release workflow

One of the biggest goals was not just "build on my machine," but "build everywhere." The workflow now produces packaged releases for:

  • Windows: .exe
  • Ubuntu/Debian: .deb
  • Fedora: .rpm
  • Arch Linux: .tar.gz

All of them are collected into one GitHub release.

The hard part

The renderer itself was not the only challenge. A lot of the work went into making the project reliable on CI and different systems.

Some of the issues I hit:

  • Apple Silicon macOS runners do not support x86 SIMD headers like immintrin.h
  • RPM packaging needed the binary path fixed so the installer could find the built executable
  • GitHub Actions artifact actions had deprecated versions that broke builds
  • Release creation needed proper permissions in workflow settings

Those were not just build issues - they shaped how the project had to be structured.

What I learned

A few useful lessons came out of this:

  • Portability matters early, not later
  • CI breaks fast when platform assumptions are too narrow
  • Packaging is part of the product
  • A renderer is more than graphics code - it's build scripts, release automation, and platform support too

What is next

Photon still has room to grow. The next steps are likely:

  • real Vulkan backend integration
  • better material and texture support
  • improved scene loading
  • more accurate indirect lighting
  • cleaner packaging for Linux distributions
  • more sample scenes and validation tests

Closing

Photon started as a ray tracer project, but it became a full cross-platform rendering pipeline with CI, release packaging, and platform-specific build support. That made it much more than "just code" - it became a small engine that can actually be built, shipped, and iterated on.

If you're into rendering, engine architecture, or cross-platform build systems, Photon is a good example of how quickly those worlds overlap.

Explore the repo: https://github.com/GordonFreeman21/photon/tree/main

Top comments (0)