This is mainly a tech demo for a 3d engine with a depth buffer. This is not finished, but I wanted to share it.
TODO:
- Optimisations maybe?
- BSP - currently model faces aren't sorted, so concave models will work weirdly. The depth buffer is only for interactions between models.
- Maybe lower the resolution for better performance?
- Some sort of culling?
- Better use of depth buffer resolution, make it more linear maybe?
(The depth buffer works with the use of colour tables, in a few passes. If anyone wants more detail, I can provide it.)
Oh yeah, controls:
WASD: Move
QE: Up/Down (relative to look dir)
Arrows: Rotate camera
Z/C: Toggle depth rendering
Thanks @freds72 and @Maeve for advice on the memory issue, I hope it's gone once and for all! (Memory still rises rapidly, so I'll look into what could be causing that too)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
I wish tline3d’s performance costs were on a per-pixel basis instead of a per-call basis. (EDIT: Hey maybe you should stop calling set_draw_target ONCE PER TLINE????!! HELLO?! -Me from the future) Currently, drawing 2 short lines is more performance intensive than drawing 1 long line. This means the goal of 2.5 screens full of tline3d per frame is almost impossible to reach. Additionally, I’m not too sure why the program is running out of memory, and it’s worrying that it messes up the Picotron os when it does (it cleared my spritesheet!!!)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/25532/icon.png)
well done!
As for performance, you have huge avenues for optimizations!
To name a few:
- stop calling functions during core rasterization loops (lerp...)
- stop "fetch"ing pod each frame (that explains the out of memory I suspect)
- ...
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
Oh, is pod causing out of memory? I shall have to look into that. I did do a test earlier by just replacing the values to tline3d with all 1. It dropped the cpu usage by roughly a third, so it wasn't too big on my priorities. I shall try that though. Thanks!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
(Updated cart) Awww, It was going so well until the web player ran out of memory. I thought i fixed that, and it's annoying that stat(0) returns 0. Still, I think it ran longer before crashing. It also runs better, although the triangles do have seams now.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/51001/6_Bunko_Says_Hi_3.png)
Ahh I've also had that problem where running out of memory will delete cartridge data. I haven't looked into it much but does the new anywhen thing help with retrieving lost data? That's how I've understood it
Also I haven't looked at your code yet but one thing that gave me a small performance boost while working on my own 3d renderer was to not update the rendering of a triangle until its rotation or position had changed by some visible threshold from the previously rendered frame (which would be some kind of function of the size and distance from camera, I forgot how I implemented it exactly, it's been a month or two since I've touched the project)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
I should definitely make some kind of performance profiler that shows how long each function takes to execute. I'm also at a dead end for the memory bug. Hmmm.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/51001/6_Bunko_Says_Hi_3.png)
I had a similar issue with it running out of memory frequently with the piconet explorer when I was creating new large userdata every frame. I believe I instead did something to the effect of creating a new one as little as possible and then overwriting past data, but that only works if it is consistently the same userdata dimensions/size I think.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
@Maeve Ohhhhhhhhhhh, That must be it! Thanks! I'll re-use the buffers for the models, it shouldn't be too hard.
[Please log in to post a comment]