DEKI/ENGINE 文档
手册 API 参考
deki-3d 0.40.1
Deki 包参考
deki-3d

以渲染通道形式实现的软件光栅化 3D:网格、透视相机以及 .obj 和 glTF 导入,与 2D 共用同一个帧缓冲。

仓库:github.com/dekiengine/deki-3d · 最新版本:0.40.0 · 需要引擎 0.40.0 或更高版本 · 依赖:deki-rendering

使用 DekiEditor --packages-add deki-3d <project> 或通过包管理器安装。引擎自身的组件和 C++ API 见 Deki 文档。

在编辑器中显示为 **3D**。

组件

组件 类别 说明
Mesh3DSettings 3D 3D 通道的绘制方式:渲染器、图块、纹理和顶点开关、线程。
MeshComponent 3D 绘制 3D 网格。由对象的变换决定其位置;场景相机必须为透视模式才能看到它。

功能开关

可以从构建中去掉的部分。带有 define 的功能通过该 define 开关,其余的随其组件一起被剥离。

功能 define 默认值
Software rasteriser DEKI_FEATURE_3D_SOFTWARE 开

组件参考

Mesh3DSettings

3D 通道的绘制方式:渲染器、图块、纹理和顶点开关、线程。

检视器中的名称:Mesh3D 设置 · 类别:3D · 类型:Deki3D::Mesh3DSettings

属性 类型 默认值 约束 说明
renderer enum "Auto" Auto, Software, GPU 由什么绘制网格。自动在平台有 OpenGL 时使用 GPU,其他情况使用软件光栅化器。软件正是没有 GPU 的开发板显示的画面,所以要在编辑器中预览它时选它;有 GPU 的地方 GPU 快得多。
composeOnGpu bool true 仅 GPU:显示通过 GPU 呈现时,在 GPU 上构建帧,把网格直接画进 2D 图层之间,而不读回。在掌机上快得多。如果帧中之后有东西要从帧缓冲区读回整个画面(全屏效果通道),请关闭它;开启时,该缓冲区只包含网格之后绘制的 2D。
tiles enum "Platform" Platform, Fixed 仅软件:图块大小从哪里来。平台使用各平台自己的值(其 DEKI_3D_TILE_SIZE 定义,没有则为 32):深度缓冲区必须放进内部 RAM 的微控制器上为 32,Miyoo Mini 上为 64,编辑器中为 128。固定则在所有地方使用图块大小。任何大小下画面都相同,只有速度不同。
tileSize int32 32 8 到 512;tiles 允许时显示 图块边长(像素),适用于所有平台。仅软件。深度缓冲区是一个图块,所以 32 只占 2 KB,适合微控制器;桌面可以用 128 或更大。
perspectiveCorrect bool true 校正纹理透视。关闭后会出现 PlayStation 时代硬件的纹理扭曲,并节省约十分之一的填充开销。
vertexSnap bool false 将投影后的顶点取整到整像素,呈现定点数时代硬件的抖动效果。
fillThreads int32 1 1 到 16 仅软件:设备或桌面版构建中绘制的线程数:它们填充屏幕的图块,并分担几百个三角形以上的网格中每个部分的几何体。1 不启动任何线程,2 适合双核开发板,超过核心数就不再有帮助。编辑器把包作为可卸载的 DLL 加载,所以始终用一个线程预览;两种情况画面完全相同。

MeshComponent

绘制 3D 网格。由对象的变换决定其位置;场景相机必须为透视模式才能看到它。

检视器中的名称:网格组件 · 类别:3D · 类型:Deki3D::MeshComponent

属性 类型 默认值 约束 说明
mesh AssetRef (Mesh) "" 已编译的网格资源。在此指定导入的模型;留空则改为绘制下方的基本体。
primitive enum "Cube" Cube, Quad, Pyramid 未指定网格资源时绘制的内置形状。
tintColor Color "#FFFFFFFF" 与网格自身的颜色相乘。白色则保持不变。
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 同时绘制网格的内侧和外侧。填充开销约为两倍。
castShadows bool true 从会投射阴影的光源(Light 的“投射阴影”)投射阴影,仅限显示通过 OpenGL 绘制时。
shader AssetRef (Shader) "" 在 GPU 上绘制此网格的 HLSL .shader。它的 Shade() 接收上面的着色模式本应绘制的内容并返回颜色;Displace() 移动顶点。为没有 GPU 的开发板构建时,只要所带的场景用到它,构建就会停止。
shaderParams Vector3 [0.0, 0.0, 0.0] 着色器以 uParams 读取的三个数:速度、强度,或者它说明需要的任何东西。
shaderColor Color "#FFFFFFFF" 着色器以 uColor 读取的颜色。

从 RendererComponent 继承 sortingOrder, ignoreClip, pixelSnap, alphaMode。

更新日志

更新日志为英文。

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.

更早的版本:CHANGELOG.md


由包的反射数据生成(引擎 0.40.1)。属性名就是场景文件中使用的键。重命名后会保留别名(兼容性)。