A CPU multithreaded pixel-by-pixel image renderer.
The crate currently only supports 24 bit color space and was mostly designed to be used in conjunction with the simple-canvas
crate and the rusty-ppm
crate, to create .ppm
format images.
Required:
Optional:
To use this crate, you will need to import the simple-canvas
crate, since pixel-weaver
uses the simple-canvas::Canvas
struct to create the image. The pixel data is wrapped inside cgmath
Vector3<_>
struct, the x
, y
and z
field acting as RGB color, so you will also need to import this one. You can also import the rusty-ppm
crate to encode the canvas into a .ppm
image, which also relies on simple-canvas
, but this is optional.
The idea behind this crate is to use it a bit like you would code a shader for a GPU. You create a function that will act upon every pixel, using only the pixel coordinate or UV to determine the final pixel color.
Tests were run 10 times each and the results were averaged.
OS: Pop!_OS 22.04 LTS x86_64
Host: 20QNS00Q00 ThinkPad P53
CPU: Intel i5-9400H (8) @ 4.300GHz
RAM: 8GB
GPU1: Intel CoffeLake-H GT2 [UHD Graphics 630]
GPU2: NVIDIA Quadro T1000 Mobile
Width: 1_000 pixels
Height: 1_000 pixels
Total: 1_000_000 pixels
Single thread: 380.341435ms
Multi thread(10): 85.168631ms
Single thread: 2.473724ms
Multi thread(10): 1.922870ms
It seems multithreaded consistently runs better than single threaded, but this might vary by the content of the pixel function, or by the machine running the code. But for more computationally heavy functions, multithreaded will vastly improve performances.