I figured I may as well make a topic for this since it seems neat, at least to me.

I'm working on optimizing a triangle rasterizer for the TI84+CSE, and possibly adding some perspective math to it to get some 3 dimensional things rendering.

Initial results:

That triangle takes about 1.25 seconds to render, so clearly the code is not very optimal. There's a lot that can be done to improve speed though, so that's what I'm doing next.

Details on what I'm doing for those interested:
I calculate the barycentric coordinates for each pixel to test if it's within the triangle, and if it is I draw a red dot, otherwise I draw a white dot.
The screen is actually stored fully in ram before being copied to the LCD to simplify rendering once I remove the visible bounding box around the triangle. It's currently 136x120 pixels (1 byte per pixel), but I'm going to switch it to 128x120 so the X coordinate fits in a signed byte. The LCD is in half-res mode, and so each row is duplicated for aspect-ratio correction. I'm using the 'xLIBC' palette for the colors.

Download here if you want to see it run (code will be available later), it's not a very exciting process to watch right now though. Requires DCSE 8.1
EDIT: Forgot to mention, press [CLEAR] to exit the program.

ALSO: If anyone can think of some practical uses for this, let me know. I'd like some ideas for things to do with this once it's running faster.
Cool =) I'm working on a scanline renderer to try and achieve something similar but with hidden surface removal as well. My guess is that a less sophisticated version of that algorithm could be used to render your triangles much more quickly, without the overhead of testing every pixel.
Looking good, i like how accurate the render is.

Have you thought about the standard horizontal line segment approach? One of the biggest bottlenecks with the CSE is accessing the screen, so negating any overdraw can be a good thing.

There are a few triangle tests for the CSE floating around, great to see you experiementing!

(Also i suggest a 3D engine of course!)
tr1p1ea wrote:
Have you thought about the standard horizontal line segment approach?

The reason I'm doing it the way I am is because the barycentric coordinates can also used for interpolating vertex attributes. This will be useful if I add textures to my triangles, which I plan to do at some point, or maybe interpolating colors for gradient effects.
(I'm also doing it that way because it's one of the simplest ways to make an inefficient triangle rasterizer Razz)

I might be able to do some combination of the two where I only do complex calculations at the start of a horizontal line, and then have a loop that just adds the deltas for the pixel while filling.
Ahh yes, very interesting.

On the B&W calcs your secondary idea was used in a couple of situations to draw basic dithering patterns etc.

Look forward to seeing more screenshots!
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum