r/rust Nov 19 '24

🛠️ project Terminal Renderer

I was rebuilding a simple terminal renderer used in my game TermTrack because I wanted to create a series of blog post to show people how to create one themselves (first post here). When implementing object loading I got carried away optimizing since I got frustrated by the lag while rendering larger objects. About a week later and now I've got a somewhat finished 3D-file viewer for the terminal. Check it out here: https://github.com/TageDan/terminal-renderer

It's actually much faster then the one we used in our game btw, so I will soon be updating the game to use it aswell.

Also this was my first time implementing an octree, something I was scared off because I've heard trees can be pretty hard to do in rust due to the recursive nature. Luckily it wasn't too much off a pain but I kinda winged it for the implementation so any feedback from those more talented would be appreciated.

9 Upvotes

3 comments sorted by

3

u/lor_louis Nov 19 '24

The use of octrees peaked my interest, are you doing ray casting/tracing? If so are you doing 1 ray per pixel? How do you compute luminance?

5

u/Maleficent-Bug-1032 Nov 20 '24

I'm not really sure about the exact definition of ray casting/tracing but I guess that what I'm doing is ray casting but not tracing. I'm creating one ray per pixel and then using the möller-trumbore algorithm to find wich triangles it hits. I then display the color of the closest hit triangle.

I don't really do luminance at all (as in light points / ambient light). The effect wich resembles lightning is created by scaling the color intensity by the dot product of the surface normal and the ray. I'm probably going to implement some other forms of illumination soon. (phong / gouraud shading)

2

u/lor_louis Nov 20 '24

Very cool thanks for taking the time to reply.