Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 45 of 45

Thread: 3D Rendering on Teensy

  1. #26
    Junior Member
    Join Date
    Mar 2015
    Posts
    13
    awesome thread, thanks! i'll keep reading for now.

  2. #27
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Had to implement a speedomeneter gauge of course This uses a background image and renders a texture quad over top for the needle. It's using tiled rendering and consumes 20kb of RAM.


  3. #28
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Going higher res and ported the 3D lib to this cheap 3.5" Kuman ILI9488 320x480 display w/ 8-bit parallel data interface On this display I was able get 49fps fullscreen color fill on Teensy 4.0. It's advertised as a pin compatible Uno/Mega display, but it was quite easy to get it working on Teensy as well. So if you are looking for a bit higher resolution display than ILI9341 to play with, this could work for you.


  4. #29
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    125
    Quote Originally Posted by JarkkoL View Post
    Had to implement a speedomeneter gauge of course This uses a background image and renders a texture quad over top for the needle. It's using tiled rendering and consumes 20kb of RAM.

    Wow, that is smooth.

    Would it be possible for you to share the code ?

  5. #30
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Squeezed the 3D lib to run on Teensy LC, not so flashy but it works!
    - Consumes 4.5kb of RAM
    - Uses 32x32 pixel tiles (8-bit grayscale frame buffer, 8-bit depth buffer)
    - 128 triangles, 64 vertices
    I'm using the standard Arduino SPI interface, which is pretty slow. Not sure if there's more optimal way to update the screen for Teensy LC (Kinetis doesn't seem to be supported).


  6. #31
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Quote Originally Posted by skpang View Post
    Wow, that is smooth.

    Would it be possible for you to share the code ?
    Thanks! I have thought of releasing the lib with samples like the speedometer, but I got quite a bit of work to get there.

  7. #32
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Here's a video about meshlet Hi-Z occlusion culling I added to the rasterizer. The occlusion culling is able to eliminate parts of the model as they are occluded by other models prior to any vertex and pixel processing thus reducing the rendering cost. In the video, when the bunny model dips into the cup the part occluded by the cup are eliminated. The culling is using meshlet bounding spheres which are tested against Hi-Z (low-res version of the depth buffer).


  8. #33
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    I'm thinking of buying these 3 displays and porting the lib to them:
    - 5" 800x480, 24bpp, SSD1963, 16bit parallel bus
    - 4" 320x480, 16bpp, ST7796S, 8/16bit parallel bus
    - 4" 320x480, 16bpp, ST7796S, 4-wire SPI
    However, what would be a good way to connect the 40/34 pin connectors in the first two to Teensy (3.6/4.0)? Obviously you can't just connect these to breadboard and hook with wires. I only need the display support, not SD card/Touch.

    Also, is there other widely used displays on the market I should consider porting the lib to? For now I have ported it to:
    - 3.5" 320x480, 16bpp, ILI9481/ILI9488, 8bit parallel bus
    - 2.8" 320x240, 16bpp, ILI9341, 4-wire SPI
    Last edited by JarkkoL; 03-22-2020 at 03:32 PM.

  9. #34
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,743
    Well you can do it with breadboards, it is just not optimal.

    What I've done in the past is solder up a prototype board with female headers for each of the Teensy pins (usually 2x12 for the Teensy 3.5/3.6 and the Teensy 4.0 with the carrier shields). And then I bring out the wire connections to a fixed order. For SPI, I originally used the order of one of the displays, but now I tend to break it out into 10 pins:
    • Power
    • Ground
    • SCLK
    • MOSI
    • MISO
    • CS pin
    • D/C pin
    • Reset pin
    • Alternate CS pin
    • Alternate CS pin


    Then I make a custom wire setup going from the standard layout to each of the devices. I use the custom crimp pin setup from Pololu to make the custom wire assemblies. One problem I've had in the past is sometimes the male pin gets pushed out of the housing, so when I make new custom cables, I plan to put a dab of glue to hold it in place.

    I put several links in the wiki:


    <edit>
    Another thing I've done in the past is lay out a breadboard or prototype board with the female headers for the Teensy, and then male headers placed in the right spot to mount the display. This way, you just move the Teensy from prototype board to prototype board. One example is the Adafruit featherwing displays aren't compatible with some feather processors (some you just cannot mount the display, some you would need to mount the display under the board), so I wired up a board to switch the around:


    The prototype board I used was from robot50.net. That person is no longer selling the board, he/she has made the PCB files available that you can make your own version:


    But if I was redoing it now, I might use this prototype board from Electrocookie that has two sets of 30 pin boards:
    Last edited by MichaelMeissner; 03-22-2020 at 06:22 PM.

  10. #35
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Ah yes, I think I could make proto boards for each display which maps from the display pins to some standard pin setup, and then another set of proto boards for each MCU to map from that standard pin setup to the MCU pins. This way I could swap MCU's and displays around without worrying about manually wiring them up every time I need to test different combinations.

    "All problems in computer science can be solved by another level of indirection" .. "except for the problem of too many layers of indirection", so I hope the wire length wont be an issue
    Last edited by JarkkoL; 03-22-2020 at 07:22 PM.

  11. #36
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Added bilinear texture sampling support for smoother texturing In the video it's toggling between point and bilinear sampling to show the difference. I'm currently supporting 23 different texture formats, so it required some template code magic to avoid code redundancy while having fairly efficient implementation.


  12. #37
    Member Etienne's Avatar
    Join Date
    Mar 2016
    Location
    Ardeche, France
    Posts
    48
    Amazing work !

  13. #38
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    170
    Agreed. Fantastic. I'm not always commenting, but I'm following this thread with amazement!

  14. #39
    Junior Member
    Join Date
    Apr 2020
    Posts
    1
    Great work! I registered an account just to keep track of this thread.

  15. #40
    Junior Member
    Join Date
    Nov 2017
    Posts
    15
    Just wanted to say this looks like a great software renderer.

    I wanted to ask if you had any connection to the demoscene at all?

  16. #41
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Quote Originally Posted by itec View Post
    I wanted to ask if you had any connection to the demoscene at all?
    Yes, I was in the PC demoscene in the 90's, but never got around to write a triangle rasterizer back in the days

  17. #42
    Suzanne on a Teensy! That's so cool

  18. #43
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    I can not believe the frame rate your getting for drawing anything to that screen. My ILI9341 takes seconds per frame. It drives me nuts! Who is this kurt and his ILI9341 library?

    -jim lee

  19. #44
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    Quote Originally Posted by JarkkoL View Post
    Here's a video about meshlet Hi-Z occlusion culling I added to the rasterizer. The occlusion culling is able to eliminate parts of the model as they are occluded by other models prior to any vertex and pixel processing thus reducing the rendering cost. In the video, when the bunny model dips into the cup the part occluded by the cup are eliminated. The culling is using meshlet bounding spheres which are tested against Hi-Z (low-res version of the depth buffer).

    Quantum physics! Nothing exists without an observer.

    -jim lee

  20. #45
    Senior Member JarkkoL's Avatar
    Join Date
    Jul 2013
    Posts
    117
    Finally got my order of few different SPI & parallel interface LCD's from China for porting the renderer to Designed unified 26pin interface to quickly swap MCU's & LCD's
    • 1.3", 240x240, SPI, ST7789
    • 3.5", 480x320, SPI, ILI9488
    • 4", 480x320, SPI, ST7796S
    • 5", 800x480, 16bit parallel, SSD1963
    • 3.5", 480x320, 8bit parallel, ILI9486
    • 2.8", 320x240, SPI, ILI9341

    Click image for larger version. 

Name:	lcds.jpg 
Views:	6 
Size:	109.1 KB 
ID:	20851
    Some more soldering to do to wire the interfaces

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •