DEKI/ENGINE docs
manual api reference
deki-3d 0.40.1
Deki package reference
deki-3d

Software-rasterised 3D as a render pass: meshes, a perspective camera and .obj import, sharing one framebuffer with 2D

Repository: github.com/dekiengine/deki-3d · Latest release: 0.40.0 · Needs engine 0.40.0+ · Requires: deki-rendering

Install with DekiEditor --packages-add deki-3d <project>, or from the Package Manager. The engine's own components and C++ API are in the Deki docs.

Shown in the editor as 3D.

Components

Component Category Description
Mesh3DSettings 3D How the 3D pass draws: renderer, tiles, texture and vertex switches, threads.
MeshComponent 3D Draws a 3D mesh. The object's transform places it, and the scene camera must be Perspective to see it.

Feature flags

Parts you can leave out of a build. A feature with a define is switched there; the rest are stripped with their components.

Feature Define Default
Software rasteriser DEKI_FEATURE_3D_SOFTWARE on

Component reference

Mesh3DSettings

How the 3D pass draws: renderer, tiles, texture and vertex switches, threads.

Inspector name: Mesh3D Settings · Category: 3D · Type: Deki3D::Mesh3DSettings

Property Type Default Constraints Description
renderer enum "Auto" Auto, Software, GPU What draws the meshes. Auto uses the GPU where the platform has OpenGL and the software rasteriser everywhere else. Software is the exact picture a board without a GPU shows, so choose it to preview one in the editor; GPU is far faster where there is one.
composeOnGpu bool true GPU only: build the frame on the GPU where the display presents through it, drawing the meshes straight into it between layers of 2D instead of reading them back. Much faster on a handheld. Turn it off if something later in the frame reads the whole picture back from the frame buffer (a full-screen effect pass); with it on, that buffer holds only the 2D drawn after the meshes.
tiles enum "Platform" Platform, Fixed Software only: where the tile size comes from. Platform uses each platform's own (its DEKI_3D_TILE_SIZE define, or 32): 32 on a microcontroller, whose depth buffer must fit its internal RAM, 64 on a Miyoo Mini, 128 in the editor. Fixed uses Tile Size everywhere. The picture is the same at any size; only the speed changes.
tileSize int32 32 8 to 512; shown when tiles allows Tile edge in pixels, on every platform. Software only. The depth buffer is one tile, so 32 costs 2 KB and suits a microcontroller, while a desktop can afford 128 or more.
perspectiveCorrect bool true Correct texture perspective. Turning it off gives the warping of PlayStation-era hardware, and saves about a tenth of the fill cost.
vertexSnap bool false Round projected vertices to whole pixels, for the jitter of fixed-point era hardware.
fillThreads int32 1 1 to 16 Software only: how many threads draw on a device or desktop build: they fill the screen's tiles, and share out the geometry of each part of a mesh of a few hundred triangles or more. 1 starts no threads at all, 2 suits a dual-core board, and above the core count it stops helping. The editor always previews with one thread, since it loads packages as unloadable DLLs; the picture is identical either way.

MeshComponent

Draws a 3D mesh. The object's transform places it, and the scene camera must be Perspective to see it.

Inspector name: Mesh Component · Category: 3D · Type: Deki3D::MeshComponent

Property Type Default Constraints Description
mesh AssetRef (Mesh) "" A compiled mesh asset. Assign an imported model here; leave it empty to draw the primitive below instead.
primitive enum "Cube" Cube, Quad, Pyramid Which built-in shape to draw while no mesh asset is assigned.
tintColor Color "#FFFFFFFF" Multiplies the mesh's own colours. White leaves them alone.
shading enum "VertexLit" Unlit, VertexLit, Flat Unlit is flat colour. Vertex lit shades each triangle by the scene's lights, from the normals of its corners. Flat shades each triangle from its own face, which is the faceted look. A scene without a Light draws every mesh unlit.
doubleSided bool false Draw the inside of the mesh as well as the outside. Costs roughly double the fill.
castShadows bool true Casts shadows from the lights that cast them (Light's Cast Shadows), where the display draws through OpenGL.
shader AssetRef (Shader) "" An HLSL .shader that draws this mesh on the GPU. Its Shade() gets what the shading model above would draw and returns the colour; a Displace() moves the vertices. A build for a board without a GPU stops while a scene it ships uses one.
shaderParams Vector3 [0.0, 0.0, 0.0] Three numbers the shader reads as uParams: speeds, strengths, whatever it says it wants.
shaderColor Color "#FFFFFFFF" A colour the shader reads as uColor.

Inherits sortingOrder, ignoreClip, pixelSnap, alphaMode from RendererComponent.

Changelog

0.40.0

Added

  • glTF models. .gltf and .glb files compile like .obj files, with their node transforms, base colours and base colour textures. Animation and skinning are not imported yet.

Changed

  • minEngine 0.40.0: built against engine 0.40.0. A build of this package from before does not load and is rebuilt.
  • A lit triangle wholly in front of the eye lights only its first corner, the one its light is taken from; all three were lit. Geometry of a scene of small lit cubes is about 9% cheaper on a desktop.
  • A background fills 4-byte pixels a row at a time, as it did 2-byte ones: the fill of a 320x240 ARGB8888 frame went from 560 to 300 microseconds on a desktop.
  • A tile with no triangle draws its background without resetting a depth buffer it never reads.
  • The pixels are the same: RasterCost draws the scene in RGB565 and ARGB8888 and prints its times and a hash of the frame.

Fixed

  • Texture coordinates far round a texture (32 turns of a 1024-texel texture, 2048 of a 16-texel one) overflowed the fixed point a span steps them in, and each processor drew its own smear. They are brought back by whole turns first; nearer coordinates draw exactly as before.
  • The table of reciprocals a span reads is made before the fill threads start. It was made by the first thread to need it, which another could read half made.
  • Vertex Lit is described as what it does: a triangle is shaded by the scene's lights from the normals of its corners, where the tooltip and a comment said each vertex was shaded.

0.30.3

Changed

  • Mesh3DRenderer::Gpu is Mesh3DRenderer::GPU, so the Renderer list shows "GPU" in English as in the other languages. Scenes keep the value, which is stored as a number; code naming Mesh3DRenderer::Gpu changes to GPU.
  • The README says where it has run: the desktop, a T-Deck and a Miyoo Mini.

Earlier releases: CHANGELOG.md.


Generated from the package's reflection data (engine 0.40.1). Property names are the keys used in scene files. Renames keep an alias (compatibility).