Skip to content

gamedevCloudy/rtx-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rtx zig

A ray tracer written in Zig

Render

Features:

  • Rays!

  • Spheres are the only supported primitives. (Can be expanded further)

  • Anti-aliasing

  • Materials:

    • Lambertian (matte)
    • Metal
    • Glass or any transparent matrials that reflect and refract light
  • Camera:

    • a camera that can be positioned anywhere
    • we can control:
      • vieport
      • aspect ratio
      • fov
      • output resolution
      • defocus blur (depth of field) - the book has a internal joke that I didn't get.
  • SIMD: some linear algebra have been converted into SIMD operstions using builtin functions like muladd. Note: This proejct can be further sped up using concurrency.

Credit:

About this project:

This was my first project in Zig. Coming from a background in gamedev, graphics have always fascinated me. I had been following ZigInDepth series on YouTube to learn Zig, but after some time it got a little boring since it does not have any projects. Jose teaches the concepts very well in the series.

I was able to follow the first video in raytracing series. This allowed me to pick up concepts which I didn't know and also showed me design choices to be made when working or translating object oriented code in C++ to Zig. This breaks many patterns from my time using Unity, and later python which I currently use at my AI Engg job.

I was able to pick up many concepts on my own after section 7.

Learning Approach:

  1. Try to follow the book.
  2. If I went wrong or get stuck follow the video series.

Overall it was pretty fun and enjoyable to make something like this. I look forward to continuing the books (there are 3) if I get free time. Thanks!

Notes:

  • I've checkpointed many small steps during the project so its easier to follow along than the reference repo which commits daywise progress.
  • I've decided to keep .ppm files which also save the moments of progress - sentimental value, since I know I would not be able to recover those over time.
  • I've moved Colors to a seprate file color.zig, to keep the color related utility seprate. This required me to do .{ .data = {some_vector}} to get a color but I've stuck to it.
  • FOV calculations: my renders do not have the save FOV as stated in book for some images, this might be due to inaccurate conversion of deg to rad. I've skipped correcting this since I continued past half the day-2 stream on my own.
  • Comments: This repo does not cover orignal books comments, but I've tried to have them where I can.
  • that's probably it, hopefully this repo serves in your learning!

About

Raytracer in a week(end).

Topics

Resources

License

Stars

Watchers

Forks

Languages