https://github.com/time4tea/raytrace-in-a-weekend-kotlin
A copy of the code from https://github.com/petershirley/raytracinginoneweekend made in kotlin
https://github.com/time4tea/raytrace-in-a-weekend-kotlin
Last synced: 3 months ago
JSON representation
A copy of the code from https://github.com/petershirley/raytracinginoneweekend made in kotlin
- Host: GitHub
- URL: https://github.com/time4tea/raytrace-in-a-weekend-kotlin
- Owner: time4tea
- License: other
- Created: 2019-01-05T23:32:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-03T19:18:56.000Z (over 5 years ago)
- Last Synced: 2025-05-05T21:46:09.314Z (about 1 year ago)
- Language: Kotlin
- Size: 6.02 MB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Raytrace In A Weekend
## In Kotlin
This is a pretty direct translation of https://github.com/petershirley/raytracinginoneweekend into kotlin.
Any bugs are my own.
Please feel free to copy / change / fork / raise issues as you see fit.
## Intel Open Image Denoise
The program incorporates the Open Image Denoise library, so the "denoised" versions are real output from this renderer.
## Example
### Cornell Box
Renders in 1.8 seconds, 20spp
Denoised

Raw renderer output

### Weekend Final Image
The below example is rendered with 2 samples/pixel, then loaded into Intel Open Image Denoise,
and renders in 0.3 seconds.

Here is the rendered output, before denoise

### Week Final Image
The Final, with *20* samples per pixel, renders in 12s, and gives the following output:
Denoised

Raw render output

### Notes about the code
- Uses Intel Open Image Denoise (oidn) Library to improve quality of scenes (via https://github.com/time4tea/oidnjni)
- Uses Kotlin Co-routines for rendering in parallel, seems fairly effective
- Uses Kotlin-Scripting for allowing dynamically-reloading scenes that can be edited while the code is running
- Has an interactive mode: use Cursor-Keys, `+`/`-` to move camera, and `1`/`2` to dec/inc number of samples, `s` to save image
### Changes from "Raytrace In a Weekend"
- Some stylistic changes for Kotlin (e.g. Hitable -> Hit? )
- Most things immutable, e.g. colours are the sum of the samples, not modified in place
- Uses x,y,z rather than an array for `Vec3`
- Added Triangle Primitive
- Added `.obj` file loading (poorly)
- Used BVH for Box
### Main Programs
- Raytrace.kt - render a scene
- ControllableRaytrace.kt - render a scene and move around it
- DynamicRaytrace.kt - render a scene, which can be modified while program is running