Now it’s time to add a texture to the cube. I’ve done this with the use of the tline function in Pico 8.
Stuff about Programming
After the last post we have solid triangles. The cube is no longer a wireframe. Unfortunately it’s possible to count the frame rate by eye. In this post I replace the implementation with another approach, called scanline rasterisation, which is significantly faster when implemented with a CPU.
For the latest update to my Pico 8 software renderer I have filled in the triangles with colour so that the cube is no longer a wireframe. To do this I reused the front function in the previous culling post. The function takes three points, a, b, and c. Previously I used the three points of the triangle I was drawing. The function returns true if the points go in a clockwise direction, and false if not. The triangle is made of three lines (a->b), (b->c), and (c->a). For any arbitrary screen pixel, if we use the points of one of the lines and then the coordinates of the pixel the function will return whether the clockwise direction is unchanged. If that direction is unchanged when using the pixel coordinates with all three lines, then that point must be inside the triangle. We can then walk through the pixels of the screen and set a colour when this condition is true.
Part 4 of my ongoing series creating a 3D software renderer for Pico 8. Click here to give it a try, and here to download it. Here are the previous posts:
This is part 3 of me walking through the process of software rendering 3D objects on Pico 8. Click here to give it a try, and here to download it. Here are the previous posts:
This is part 2 of me walking through the process of software rendering 3D objects on Pico 8, click here for part 1. In this post I’m projecting a wireframe cube made up of triangles. Click here to give it a try, and here to download it.
This Pico 8 cart projects a square in 3D space onto the screen. Click here to give it a try, and here to download it.
I made a Pico 8 cart which produces a SNES Mode 7 style floor. The trick is in the function tline, which draws a line between two points, sampling from the map data along the way. You give it the map position to start from, as well as dx and dy values it should use as an increment after each pixel. The other main thing is setting a depth value per scanline, the closer to the bottom of the screen the nearer to the player’s view. The rest is just trigonometry, applying angles to vectors using sin and cos.
A lovely book, easy to read and clear. There are some typos in the code examples but that was literally always the case back then. It was a part of how you learnt I think, forced you into figuring it out.
Pretty short but clear book on Erlang. The first half consists of things I’m familiar with already (immutability, pattern matching, recursion, higher order functions). It was the last half that I was more interested in, process oriented programming and OTP. I’ll have to read a more in depth book to understand it thoroughly, but it’s a very interesting approach.
Python has an http server in it’s standard library, and if you invoke the module directly from the command line it conveniently serves the local directory:
I can never remember the command to delete remote git branches, ending up on the page in the git book. Maybe writing it down here will help:
My configuration file for tmux has changed a lot over the years. I ended up with all sorts of custom settings after reading tmux by Brian P. Hogan, and the Arch Wiki page. Both are great resources, but I ended up with a config file that I didn’t fully understand or use. I’ve since trimmed it down to only the parts I use regularly. This should also make upgrades easier, since tmux has a habit of breaking config file compatibility between versions.
I have a little git repository for keeping recipes. They’re all Markdown files, and I use pandoc to convert them into pdfs. I’ve created a Makefile for doing the conversion:
I love video games, and partly started programming in the first place to learn how they work. Recently I’ve been learning OpenGL in an effort to try and build a simple game engine.