It is always a good idea to create a visible output at the start of a long project. If you are making a game, start with showing something moving on the screen. It keeps you motivated and gives you something cool to show your friends as progress. In the second part of our ray tracer tutorial, I will introduce you to PPM a very simple image format that will be used for our renders. You don’t need to install any image libraries and yet PPM files can be read by most image viewers.
The color class is a lot simpler than what I originally designed. Features like gamma correction and linear interpolation seemed like an overkill for a project like this. But I plan to add some convenience constructors later. Hopefully, this will be a good introduction to how colors are manipulated in computer graphics.
These are the topics we will cover in this episode:
- Compressed Image are Hard
- What Images are Made of
- RGB triplets
- First sub-problem: Revealing the True Colors
- Coding the solution
- Use the shebang line
- Separate classes in separate files
- Why fileobj instead of filename?
Here is the video:
Code for part two is tagged on the Puray Github project
Bonus (Gradient) Code is available for download.
Books and articles that can help understand this part:
Understanding Compression by Colt McAnlis, Aleks Haecky A book covering image formats like JPG, PNG etc
Python Imaging Library PIL or Pillow Popular Python library for reading and writing different image formats
A Field Guide to Digital Color by Maureen Stone Understand color theory beyond RGB triplets into vision and various color systems.
Note: References may contain affiliate links