MMD for esp32
Source code is available at github.
MMD for esp32, M5Stack, (WiFiBoy32 page)
Resolution:320x240
FPS: 22~26fps
RAM: about 300KB
Triangles: 2450
Vertexes: 3337
Bones: 92
Thread: 2 (barrier sync)
Memory usage (estimates):
Memory usage | for each element [byte] | total [byte] | % |
Triangle buffer | 136(shape, count, UV, ...) | 136*300=40800 | 13.6% |
Vertex buffer | 4*4=16 | 16*3337=53392 | 17.7% |
Z buffer | 2(2 byte)*window_width*DRAW_NLINES=25600 | 25600 | 8.5% |
Draw buffers | 2*window_width*DRAW_NLINES=25600 | 25600*2=51200 | 17.1% |
Bone matrixes | 64(Matrix)*4+4+4*3=272 | 272*92=25024 | 8.3% |
Animation position, rotation, frame | (3+4+1)*4*2=64 | 64*92=5888 | 2.0% |
Vertex matrixes | 64 | 64*150=9600 | 3.2% |
Others (stack, threads, or used in os) are excluded in the table.
DRAW_NLINES is const variable how many horizontal lines is send to the LCD at the same time. The Larger the number of horizontal lines, the faster and smooth animation, but It takes lot of RAM.
Double buffering method is used and CPU task which draw the 3D model and send to LCD is executed simultaneously.
Triangles which is spanning two DRAW_NLINES area is stored in the Triangle buffer.(Red triangle in the picture below)

Triangle which behinds the camera Z-clip.
Pattern 1, 2 vertexes are behind the camera. move two vertixes to the ZNEAR

Pattern2, 1 vertex is behind the camera. Then, split one triangle into two triangles.

==TODO list==
- refactor (especially skeletal animation source code)
- multiple models to show stage, other 3D models and so on.