.gitignore | ||
image.ppm | ||
LICENSE | ||
main.go | ||
README.md |
RaytracerGO
A raytracer and renderer writen in Go (Golang) following the book Raytracing in one weekend
Motivation
I've been meaning to tinker with graphics for quite a while and was motivated by a video programming a raytracing algorithm on a TI-84. Back in my school days I used to love to tinker with the TI-84 and also did some very elementary programming on it myself.
Video that started it all: Raytracing on a Graphing Calculator (again)
![TI-84 Raytracing](https://www.techeblog.com/wp-content/uploads/2022/12/ray-tracing-ti-84-plus-ce-graphing-calculator.jpg)
Why Go?
The story starts with Zig. A few colleagues of mine and I tried to work on a Guake-like browser using Zig. We chose Zig because it's C-like, modern and because their mascot is a lizard, of course. But I don't like Zig all that much, and right now Go has caught my attention.
I like the language a lot, it's still very C-like, doesn't have classes :), is open-source and resembles Python a lot, while still being fast and having crazy fast compiling speeds (which is something I've started to appreciate since dabbling with Linux From Scratch). The only draw back of Go is that it is a little bit slower than C++, but I just want to experience what the Python-version of C is like :)
![Go-Programming](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fprogramaenlinea.net%2Fwp-content%2Fuploads%2F2020%2F04%2Fgolang-1024x516.png&f=1&nofb=1&ipt=363a10979aa43c8925c481b76c8a2b03a50ce948b3548b40a29432caf8a534d1&ipo=images)
Taglibro
Chapter 1: The PPM-image format
![First PPM image](https://raytracing.github.io/images/img-1.01-first-ppm-image.png)
Yay this is the first image I've ever generated without using any external imported library ^^
Chapter 2: Vector operations: Ditching OOP for GO
Implemented the vec3 Class and colour utility functions without classes. Struktoj estas sufiĉa.
Chapter 3: Implementing the camera, rays and a background
To understand computer graphics better I will try to describe some important definitions with my own words:
- Rays: A ray is a 3D-vector with an origin pointing with some length in one direction (P(x)=O+x*b, where O is the origin and b is a vector pointing in one direction)
- Viewport: Is essentially a window (typically the user window) through which we see the 3D environment. Adjusting the viewport allows you to zoom in, pan around, or focus on specific areas of your scene.
- Camera: Is essentially a mathematical function (a virtual eye of sorts) that captures rays that originate from its position and pass through the viewport and generates an image that the user can see.
By the end of this chapter I generated the following background:
![Second PPM image](https://media.discordapp.net/attachments/1185146037774602320/1203455065361489920/image.png?ex=65d127de&is=65beb2de&hm=236433d19502d5b96e041838afe58191f4242f27a79abe32b8689ff80799b64c&=&format=webp&quality=lossless)