Skip to content

effekt-community/tracing-effective-rays

 
 

Repository files navigation

Note

This is a community-maintained fork of a MIT-licensed student project in the Effective Programming with Effects course in winter semester 2025/2026. Be warned that this is not an officially endorsed project, the code in this repository may be not idiomatic Effekt.

The original repository is https://github.com/mattisboeckle/tracing-effective-rays

Table of contents


Overview

This project is part of the "Effective programming with Effect" course at the University of Tuebingen. The aim of this project was to implement a simple raytracer based on Ray Tracing in One Weekend in the Effekt programming language.

"src/main.effekt" contains the scene, camera & rendering parameters that can be customized. The program will render an image based on the parameters and produce an image at "out.ppm".

"src/demo.effekt" contains some examples on how this project works. It is recommended to start a repl using effekt --backend llvm, import the demo file with import src/demo and then run one of the demo functions demo1() etc. which will produce an image corresponding to their name in the project root.

Example renders

10 samples, 2 bounces

50 samples, 5 bounces

100 samples, 10 bounces

Hollow glass Two Metal

Installation

Only requires the Effekt language https://effekt-lang.org/docs to be installed with at least one working backend. LLVM is recommended.

Useful commands

Effekt commands

Run the main file:

effekt src/main.effekt

This (like many other Effekt commands) uses the JavaScript backend by default. To use a different backend, add the --backend <backend> flag. The LLVM backend --backend llvm is recommended for speed, but all backends that support writing files should be supported. Only LLVM and JavaScript have been tested.

Run the tests:

effekt src/test.effekt

Open the REPL:

effekt

Build the project:

effekt --build src/main.effekt

This builds the project into the out/ directory, creating a runnable file out/main.

To see all available options and backends, run:

effekt --help

Nix-related commands

While Nix installation is optional, it provides several benefits:

Update dependencies (also runs automatically in CI):

nix flake update

Open a shell with all necessary dependencies:

nix develop

Run the main entry point:

nix run

Build the project (output in result/bin/):

nix build

Example projects using this template

Repository structure

  • .github/workflows/*.yml: Contains the CI definitions
  • src/: Contains the source code
    • main.effekt: Main entry point
    • test.effekt: Entry point for tests
    • demo.effekt: Contains demo renders
    • lib/: Library code imported by main and test
  • flake.nix: Package configuration in a Nix flake
  • flake.lock: Auto-generated lockfile for dependencies
  • LICENSE: Project license
  • README: This README file

CI

Two GitHub Actions are set up:

  1. flake-check:

    • Checks the flake.nix file, builds and tests the project
    • Runs on demand, on main, and on PRs
    • To run custom commands, add a step using:
      • nix run -- <ARGS> to run the main entry point with the given arguments
      • nix develop -c '<bash command to run>' to run commands in the correct environment
  2. update-flake-lock:

    • Updates package versions in flake.nix
    • Runs on demand and weekly (Tuesdays at 00:00 UTC)

About

originally mattisboeckle/tracing-effective-rays

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Nix 100.0%