Pure rust, pure software, minimal rasterizer

I have the following problem:

* Color = (u8, u8, u8)
* Location = (f32, f32, f32)
* Point = (Location, Color),
* Triangle = (Point, Point, Point)
* CameraMatrix = Mat4
* Input = Vec<Triangle>, CameraMatrix

Output: rasterized image.

  1. I don't want to use OpenGL. I am looking for a pure software solution.
  2. There is no texturing. Each point in the triangle just takes weighted avg of the 3 vertices.
  3. In case of "z-fighting", outputting either color is fine.

Is there an existing crate for solving this? I prefer minimal dependencies / something hackable.

Could always use a software backend of OpenGL, like Introduction β€” The Mesa 3D Graphics Library latest documentation

If you're interested in file output, something like png looks reasonable β€” you hand it an array of pixel values and you get back an image file. The rasterizer math you want isn't too bad to do by hand if you don't care about rendering speed.

1 Like

Would GitHub - zesterer/euc: A software rendering crate that lets you write shaders with Rust help?

1 Like

You may want to take a look at my retrofire project. It does what you want, but you may need to hack it a bit and cherrypick the pieces you need if you want a truly minimal solution. It’s not (yet) at crates.io as it lacks docs and needs some API design and cleanup. Licensed under Apache2/MIT.

@jdahlstrom : I am a big fan of demo scene. Quick question: what types of things can retrofire render in real time ?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.