Smolpix: very tiny image generation toy

SMOLPIX


https://codeberg.org/tgirod/smolpix

Smolpix is a toy application to generate animations with a very simple stack language - think shadertoy meets forth. The program generates an animation of 256 frames of size 256x256. each pixel is computed based on three parameters (x,y,t) and their combinations through various arithmetic operations and functions. The stack language manipulates onl u8 and uses modulo operators, so using multiplication usually gives wild results!

This project is my playground to learn more about SIMD and performance in general, and to have an excuse to play with my computer. :slight_smile:

There are probably many things I could improve in terms of usability (making the program not explode when your script is invalid) or performance (I could generate the frames in parallel).

The code is pretty much its own documentation right now, but I think it is pretty straightforward. Feel free to give me feedbacks!

Supported Zig versions

version 0.16

PS: I’m so happy there is a “handmade” tag !

13 Likes

This is super neat! I’ve been using raylib lately, and it’s a lot of fun

1 Like

@glitchcake thanks!

The latest version has seen massive performance improvements compared to the first naive version, thanks to computing pixels with SIMD instructions, and computing frames in parallel with the new Io interface.

However it doesn’t compile in ReleaseFast right now, but it seems to be linked to zigraylib. The linker error is beyond me right now.

2 Likes

super cool, will this become a tool you will use in some scenario?

My original idea was to put this in an android app, and share the programs through the payload of a virtual BLE beacon (31 bytes), so it propagates like smallpox, hence the name of the project. :slight_smile:

But honestly, I’m not sure I will go this far, because compsci is not my job anymore and I do that on the side just to have fun and to keep my programming muscle alive …

UPDATE: latest version gives more informations about available words and validate the program before executing it. much more usable!

2 Likes

latest commits add HSV to RGB conversion. It was an interesting challenge to modify the algorithm in order to represent floating values in range [0:1] with u8, and to make heavy use of saturating operators in order to vectorize some parts.

PS: I get nice rainbows but I think the hue phase is wrong, there are probably bugs somewhere …

1 Like