3

It is possible to an Arduino render 3d graphics like very low polygonal 3d models or generating lighting efects non realtime shadows or realtime shadows and reflections. Rendering like first 3d video game consoles. Someone can ask why you don't use an Rasberry Pi. Beacuse Linux can be more complex. Also Rasberry Pi is a computer runs Linux .Linux is hard and some people can say you can install Windows but it doesn't give freedom as Arduino on Arduino you have more control on system.It doesn't run operating system but Rasberry pi runs and you needed write programs for it. You can't do much anything ( at least i know) than Linux or Windows will allow.

My goal was running very basic 3d graphics on a Vga. Theres no rule it can be like old dos games.Fake 3d effect like distorting sprites to look like 3d and rotate them move change coordinates change camera position like a 3d but it's actually generating fake depth. Must camera position controllable . Like a video game.

Sprites,effects are completely pre rendered. Only realtime rendered thing was distorting sprites by camera position. Changing room (Square area will reset view that will make after another room it would show another room).

Is there a library can done that?

Your solution can be for another Arduinos.

Your solution can be Arduino dependent. Like only works for due,mega etc.

Theres a vga library for Due supports 256 colors your solution can use this library problary called DueVGA

1

5 Answers 5

1

While there is no VGA library for Arduinos with AVR, there is one for ESP32: ESP32 VGA Library.
It makes heavy use of the Hardware capabilities like I2S that are not present in in Arduino.

0

VGA

I suggest you build the famous world's worst video card. It's a great project and you'll definitely learn something when building it.

That graphics card uses only 2 bit per base color, which is 6 bits in total, or 64 colors. The resolution of the graphics card is 100x75 pixels. An image can basically become as good as

Finch

That picture is still 100x75 = 7.5 kB in size. That means it does not fit into the 2 kB of RAM of an Arduino Uno.

To clock the graphics card, Ben Eater uses a 10 MHz crystal to get the timing right. That means, your Arduino needs to output one color at a speed of 10 MHz. That's clearly not feasible for an Arduino Uno running at 16 MHz.

However, an Arduino Uno is nothing without some hardware attached. You could try to calculate the 3D graphics on the Arduino and write the results into an EEPROM (just like Ben Eater's graphics card) and let the EEPROM handle the output of the colors. That way, you could certainly generate single images. The frame rate will definitely not be high.

But: your request is not far fetched. My first computer, an Apple IIe was running at 1 MHz speed - but at least it had 64 kB of RAM. It could do all sorts of stuff, although I can't remember a 3D game. Using an Arduino Due with 84 MHz and 96 kB of RAM should be a realistic approach - and probably the reason why DueVGA exists.

TFT

A TFT display already has its own memory, so you needn't worry about that aspect. People already did 3D rendering, although they were going through a lot of problems that I mentioned for VGA before. It requires a lot of optimization. A library is the ATmega328 Tiny 3D Engine.

With shading it seems to render up to 3 frames per second on an Arduino, which is likely not enough to for smooth interaction.

Raspberry Pi

Linux is hard

Some Linuxes are. Especially Kali Linux. But Raspbian is really a good OS for the Raspberry Pi. We are teaching internships Linux + Shell + Python in 1 week (like this project). It's enough to focus on the programming. Not much configuration needed.

You can't do much anything ( at least i know) than Linux or Windows will allow.

That might be true. However, I am developing software that runs on operating systems since 1996 and have never had the feeling that the operating system restricts me from doing something. In the opposite: the OS provides features that would be very hard to implement on my own.

2
  • Thanks but i saw some people really rendering 3D on Arduino: hackaday.com/2016/01/02/better-3d-graphics-on-the-arduino (TFT) Also i remember theres a library for noki a lcd's but i don't know but i can't find code for it. Even i do it. It just be distorting shapes for look like 3d. It will not render as showed in article. May 5, 2020 at 23:03
  • @IWantJustBasicCollisions the guy in that video is doing VERY advanced optimization and going to great, elaborate lengths to create seemingly impressive, but actually rather crude results. They are not really practical for a game. If you want to write video games, use a platform that has a built in video output with graphics support. Rolling that stuff yourself is really, REALLY hard, and the results are pretty limited.
    – Duncan C
    May 6, 2020 at 23:20
0

I disagree with your premise. If you use a high-end Arduino, like one of the ones based on an ARM processor, and you optimize the snot out of it, you might be able to generate crude VGA level graphics, and gin up some 3D looking images. But expect to spend a lot of time on very fussy timing code that requires a LOT of expertise to get right.

(An Arduino does not have any display driver at all.)

You want a device that can output video through hardware. A Raspberry Pi is a much, much better choice. Sure, it runs UNIX. UNIX isn't going to bite you. Roll up your sleeves and

0

On AVR based Arduinos: No, definitely not. It is possible to create a VGA signal, but only with very limited resolution and few colors (like 4 or so) and also a framerate, that will not be enough. Also they all have too few memory.

It might be possible on the Due (don't have much experience with it), but it is still a bad choice for a platform (also partly because the Due is in general such a bad designed board with no good documentation).

Is there a library can done that?

I don't think, that you will find any library doing all what you want. You might find libraries, that help you draw on the display, but you will do all the hard stuff (creating and loading sprites, distorting them, animating them) yourself. This is, because Arduino is a bad choice for such a project.

Also: In the title you mentioned TFT. I guess you meant one of the TFT display modules, that you can connect to Arduinos. Forget about that. They are connected over rather slow serial data interfaces (not meaning the Arduino Serial here, but serial interfaces like I2C or SPI). You won't get a sufficient frame rate with them.


I would oppose your arguments against the Raspberry Pi. Sure, it has an OS, but that also means, that it can make use of a variety of languages and frameworks. You are not bound to plain C/C++. You can use the language or framework, that best suites your needs. That can be a bit complex at first to find the right one. But thats, because your project is complex. What you are describing is a very complex task, when you cannot rely on others, that have already implemented the hard stuff (which would be the case for the Arduino).

Also a Raspberry Pi has plenty of RAM and plenty of storage space. It runs at high speed and is actually capable of outputting video with a good framerate.

Without wanting to offend you: I think, as you are asking this question here, you are not qualified enough yet to do such a project on an Arduino. There are insanely capable people out there (wouldn't count myself to them), who do incredible things with Arduinos by milking the very last drop of resources out of them. But they are doing it for the grind, not for having a functioning product at the end. I guess you want this to work good at the end, without needing you to work on it for many years. Then you are result-focused and should choose the correct platform for this. A computer (like the Pi) will be easier.


Rasberry Pi had lot of things but some of them are unnecessary.

Yes, but is that really a problem? Is the unused potential really a no-go for the project? You could say the same thing about an Arduino. It has a lot of peripherals build in (depending on type Timers, Comparators, ADCs, DACs, several communication interfaces, power management peripherals, ...). Almost no project uses all of them. But that's simply the difference between general purpose chips/boards (like all Arduinos or Raspberry Pis) and custom made chips for a single purpose. If (!) a fitting chip for your project exists, that really only has what you need, it will most likely be very expensive. Chips for a single very narrow purpose have a very narrow target group, thus are more expensive (simple economy here). Companies have formally nearly everytime designed their own chips for gaming consoles (which is way beyond your current scope), like PS1 or N64. Current gaming consoles rely often on modified standard hardware, also because it is cheaper. The really old gaming consoles used the generic electronical chips, which means, that you didn't have one single programmable chip. Instead lots of the logic was build into the electronic design.

So you will always have some excessive features, that are not used. Why would you want to remove them from the project, just for the fuzzy goal of not wasting features. It will make your project only more complex and expensive. You will gain nearly nothing from minimizing the resources. This is a hobby project, not for selling it.

In rasberry pi you just writing a computer program.You don't have much control like arduino

That depends on what type of control you mean. On a computer you are writing code on a higher level of abstraction. That also makes it easier to do complex things, since you can rely on the low level programming of others. What control do you want to have over the system, that you don't have on a computer like the Pi? Do you think, you can program better display drivers or graphic renderers, than all the other people? Then you can still do that on the Pi. A Pi also gives you control over the GPIO pins, which let's you do many hardware things, that you can also do on an Arduino.

Also Linux is open source. If you think, you need more low level interaction with the hardware (cannot think of a reason for needing it), then you can build your own OS, which gives you the needed freedom. Sure, that is very complex. But when you are able to use the low level programming, then you are also able to change the OS.


You seem to already have chosen the Arduino for your project. I, like others, have advised you to use a Pi instead to make it a lot easier and better. It is up to you, if you want to believe us or not. All in all I'm still not convinced, that you are able to pull that off on the Arduino platform, while still getting good results. You are simply not at that point of knowledge yet. You write confidently about the problems with an OS, while you don't seem to have a concept about the exact structure of these problems and how they impact you. We will not prevent you from doing it the hard way. Please for free to choose your own way.

6
  • You are right but Rasberry Pi like overkill . Also i don't want build a computer in my goal. Also on rasberry pi and other linux systems had very complex commands. Running 3D graphics on rasberry pi just making a video game for just a linux computer. Arduino feels more user friendly also i didn't used Linux i used in school on smart boards it's not a Linux Linux-Based os called Pardus can run some exe files if i remember correctly May 5, 2020 at 23:10
  • I don't think, that a Pi is overkill. It is a good way to go for a beginner. You could use the Pi Zero, which is very small (smaller than an Arduino Uno). The commands can be less complex than on Arduino, because you don't need to do the nitty optimization stuff. But sure, I don't prevent you from doing it with Arduino. If you like the very steep learning curve, then it is good. Not just something I would recommend
    – chrisl
    May 6, 2020 at 7:49
  • In rasberry pi you just writing a computer program.You don't have much control like arduino(at least i know). It just a program runs on a rasberry pi. Rasberry Pi had lot of things but some of them are unnecessary. Is there another embeded system had 1 gb ram but doesn't run os like rasberry pi does. You have full control over system. Microcontroller or Microprocessor supports 1 gb of ram and rendering 3d (like ps1).I don't want os even it had os It just like MS-DOS. Linux or Windows. You still depending on os. If you just want special tasks run. Not like explorer.exe running background or etc May 6, 2020 at 12:18
  • A Raspberry pi is not overkill. It's the right tool for the job. An Arduino is woefully under-powered to do ANY kind of graphics. It's too slow, has too little memory, and has too low I/O bandwidth. Most Arduinos don't even have enough RAM to display a single frame of VGA color graphics, never mind the memory needed to manipulate an array of vertexes and render it to full-screen color output. Then there is the fact that they don't have native floating point, and you really need specialized graphics hardware to do 3D graphics with a decent frame-rate. (Software floating point is SLOOOOOOOOOW.)
    – Duncan C
    May 6, 2020 at 22:22
  • @IWantJustBasicCollisions I added some explanations to address directly some of your arguments. I don't think, that you are right. Though, as you already seem determined to stay on the Arduino framework, this is the last piece, that I will write for this question. You can choose the easy or the hard way as you like. Please decide yourself on what you want to do.
    – chrisl
    May 7, 2020 at 8:03
0

You can definitely render 3D graphics on an Arduino-based MCU & TFT and I have done exactly that with Teensy.

It requires quite a bit of work to implement software rasterizer though and I'm not aware of an off-the-shelf 3D library you could use. I would think that someone has written a 3D graphics iib though, so might be good to scour GitHub if you don't want to write a rasterizer yourself.

There are plenty of different TFT options with both SPI (serial) and 8/16bit parallel interfaces you can use and have decent frame rate. E.g. with Teensy you can update a 320x240x16bpp screen over SPI at ~30fps. You can also pass SPI data transfer to DMA to free spending MCU cycles for it if your MCU supports it. With parallel interface you can bit bang the data to TFT faster and have potentially higher frame rate, but then you have to waste MCU cycles for the data transmission.

Newer Teensy models has plenty of RAM (1MB) for 3D rendering but it can be quite challenging to render 3D graphics on some MCU's with only few kilobytes of RAM. I'm using tiled rendering, which renders a frame in small tiles (e.g. 64x64px) and thus doesn't need to maintain the whole frame & depth buffers in memory. Because of this I was able to get the 3D renderer running on Teensy LC, which has only 8kb of RAM, but it's much slower and simpler 3D model. I also store the 3D assets (geometry, textures) in the MCU flash in format that can be directly used for rendering to save RAM.

You can also implement texture sampling on MCU, which opens possibility to implement various different effects, like sprites you mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.