Writing a raytracer in Go #1: Introduction

Two weeks ago I was at GopherCon Brasil 2019 at Florianópolis for the first time ever. There were a few interesting talks discussing Go’s compiler, linters, GoCV with Tensorflow and HuskyCI (which you should definitely check out).

However great the talks were, the event was especially important to remind me that I genuinely like what I do. Between work and university, it’s really easy to forget that I also like to program as a hobby.

me and the gopher plush
Sadly, I was not able to get a Gopher plush for myself 🙁

So, after two days of event and sleeping around 18 hours in 3 days, I did the only logical thing when I arrived home: I spent all day programming.

Ok, what about the title?

I have always liked computer graphics. Even when I had no clue what computer graphics were (sometimes I still don’t to be honest). So, when I started studying Computer Science I was naturally drawn to develop graphics-related stuff and, a few years back, I started writing a raytracer in C++.

Of course, I have not finished it. Who even finishes projects, am I right? *laughs nervously* But really, I learned a bunch of stuff with the overall process and it was one of the projects that most helped me grew as a developer.

That been said, what do I want by writing a raytracer in Go?

Practice Go

Go is one of my favorite languages to work with for a bunch of stuff. It’s probably the one I use the most at work and it will be interesting to use it for something other than web development.

Even more, I think I am already comfortable enough with Go as a language and will not need to spend time that I don’t have struggling with a technology I’m not familiar with. It would be a really interesting project to develop in Rust, for example, but it’s not my goal here. Maybe in the future?

Revisit my C++ code

My C++ raytracer was mostly based on Kevin Suffern’s Ray Tracing from the Ground Up book, although a good part of my current code differs from Kevin’s version. Much has been learned since my last commit a couple of years ago.

I’m really interested in seeing how much I have changed as a developer after working for two years in the technology industry. I want to see how I would write this code today, hopefully, without making the same mistakes.

Get further than before

If we use Kevin’s book as a roadmap, I have reached roughly half of it. My raytracer goes as far as rendering shadows and specular reflection of simple primitives like spheres and planes. With this new raytracer, I want to learn and to implement new techniques.

Write about the process

I have this blog for a few years now and the lack of posts has always bothered me. I probably have more drafts than published posts and I really wanna change that.

Having ideas for posts has always been difficult to me, starting to write once I had them was not so difficult but, actually finishing a post is way harder. Writing about the development will at least spare me the process of having ideas of what to post. Easing this problem will leave me time to worry more about how to conclude my posts.

Have fun

Finally, I started writing a raytracer not because I needed for an assignment or because I wanted to find a related job. I started it because I thought it was going to be a fun hobby and a great programming challenge (having much free time helped as well).

This time is no different. Between working and studying, I have dedicated so little time to programming as a hobby and I want to change that.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.