chipKIT® Development Platform

Inspired by Arduino™

Time to really show off DisplayCore

Created Sat, 02 Apr 2016 00:20:24 +0000 by majenko


majenko

Sat, 02 Apr 2016 00:20:24 +0000

DisplayCore, the Premium quality (yet open source) TFT and graphics library for chipKIT boards has been undergoing a bit of an expansion over Easter.

I spent my time, instead of eating chocolate eggs, programming a simple 3D engine for DisplayCore.

Yes, you heard me right, 3D. It's not fancy 3D like you have in your modern computer games, no. This is simple triangle rendering in a 3D space. Triangles are the simplest of components to work with in 3D - kind of like the equivalent of a pixel in 2D, only you can't have as many of them because there's not enough memory for lots.

You can have a couple of thousand though, and that can make quite a decent representation of data in 3D. Take for example this 32x32 plasma fractal landscape rendered in 3D on a WiFire Rev C (the one with the FPU, which is normally not active but can be activated easily enough if you use UECIDE). That's 1922 triangles all being rendered and lit and moved around, and it only takes about 140ms to render the whole image.

[youtube]https://youtu.be/MMcD17xYcVc[/youtube]

(You'll have to excuse the quality of the video - it's not easy filming a TFT, and that isn't the best TFT around - the contrast ratio is pretty poor.)

Now imagine what you could visualise with that... Heat maps? Frequency vs Amplitude vs Time? The possibilities are endless. And of course you aren't limited just to surfaces like that. Triangles can be joined together to model anything you like.


majenko

Sun, 17 Jul 2016 14:06:28 +0000

I have found a bit of time this weekend to revisit my 3D algorithms, and I've added a couple of new, higher quality, ones.

We now have ray casting! Ray casting is like ray tracing, but the rays don't reflect, refract, cast shadows, etc. We also have barycentric vertex shading! That is when each vertex of a triangle (corner point) has a colour assigned to it and the colour at each point within that triangle is calculated depending on its distance from the three vertices. However, the vertices don't actually have a colour, only the triangles do - so each vertex has its colour calculated from the average of the colours of the triangles that meet at that vertex.

So you get really nice smooth shading.

Here's an example. First the normal triangle drawing from before:

[attachment=1]IMG_20160716_222711.jpg[/attachment]

And now the same scene rendered with ray casting and barycentric shading:

[attachment=0]IMG_20160716_221113.jpg[/attachment]

Just a bit of a difference, don't you agree?

The down side is it takes about 15 minutes to render the scene - even with 200MHz and an FPU.


EmbeddedMan

Mon, 18 Jul 2016 21:53:18 +0000

Wow, again, very nice job Matt. This is really sweet, even if not very practical for real time video frame generation. :-)

*Brian