Time to really show off DisplayCore

Show off your projects to others!
Post Reply
User avatar
majenko
Site Admin
Posts: 2164
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Time to really show off DisplayCore

Post by majenko » Sat Apr 02, 2016 1:20 am

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.



(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.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

User avatar
majenko
Site Admin
Posts: 2164
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: Time to really show off DisplayCore

Post by majenko » Sun Jul 17, 2016 3:06 pm

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:
IMG_20160716_222711.jpg
IMG_20160716_222711.jpg (1.19 MiB) Viewed 416 times
And now the same scene rendered with ray casting and barycentric shading:
IMG_20160716_221113.jpg
IMG_20160716_221113.jpg (1.21 MiB) Viewed 416 times
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.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Time to really show off DisplayCore

Post by EmbeddedMan » Mon Jul 18, 2016 10:53 pm

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

*Brian

Post Reply