You are reading a post from a multi-part series of articles
- Ray Tracer in Python (Part 1) - Show Notes of "Points in 3D Space"
- Ray Tracer in Python (Part 2) - Show Notes of "Revealing the True Colors"
- Ray Tracer in Python (Part 3) - Show Notes of "3D Balls in 2D Space"
- Ray Tracer in Python (Part 4) - Show Notes of "Let there be light"
- Ray Tracer in Python - Show Notes of "Ray Tracing a Coronavirus"
- Ray Tracer in Python (Part 5) - Show Notes of "Some Light Reflections"
- Ray Tracer in Python (Part 6) - Show Notes of "Firing All Cores"
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:
- Introduction
- 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.
Show Notes
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