Skip to content

GPU Rendering and OIT

kltyton edited this page Dec 1, 2026 · 2 revisions

GPU-driven entity rendering, skinning, OIT and emissive overlays

English | 简体中文 · Home

In 0.5.1-lite, com.kltyton.bedrockruntime.client.render.gpu provides a complete GPU-driven entity rendering pipeline — instancing, 4-bone linear blend skinning (LBS), frustum and Hi-Z occlusion culling, instance compaction, indirect multi-draw command generation, geometry LOD selection, fullbright GPU EMISSIVE rendering, and weighted blended Order-Independent Transparency (OIT) across all ten loader targets, with automatic CPU fallback when external shaderpacks are active.

Shared pipeline and data layout

Type Role
SkinnedMeshCompiler / SkinnedMeshData Compiles BedrockModelAsset geometry into 56-byte interleaved vertices (pos, normal, uv, 4 bone indices, 4 weights)
SkinnedMeshLodGenerator / GpuLodSelector Builds multi-LOD mesh levels and selects geometry LOD by distance and screen-space coverage
BoneMatrixPaletteBuilder / BonePalettePool Packs 3x4 affine skinning matrices into a zero-offset pooled palette buffer with matching CPU LBS evaluation
PersistentGeometryBuffer / GpuResourceLifecycle Retains static mesh vertex/index buffers in VRAM across frames with frame-fenced deferred disposal and live-byte accounting
GpuFrustumCuller / HiZOcclusionCuller Performs frustum plane tests and reverse-Z / standard-Z Hi-Z depth pyramid occlusion culling
GpuInstanceCompactor / IndirectDrawCommandBuffer Compacts visible instances and emits 20-byte DrawElementsIndirectCommand batches grouped by MaterialBatchSorter
DecoupledRenderPipeline Decouples per-frame Extraction, Submission, and Drawing into immutable stage snapshots
GpuInstanceBatcher / InstanceData Batches 64-byte per-instance payloads (modelMatrix, tint, overlay, light, palette offset) by InstancedBatchKey and GpuMaterialMode (SOLID, CUTOUT, TRANSLUCENT, TRANSLUCENT_OIT, EMISSIVE)
GpuShaderConflictDetector Detects active external shaderpacks (e.g. Iris) so batching yields cleanly to the CPU fallback path
SkinnedMeshData mesh = SkinnedMeshCompiler.compile(modelAsset);
InstancedBatchKey key = new InstancedBatchKey(
        modelAsset.resourceId(), modelAsset.generation(), textureId,
        GpuMaterialMode.CUTOUT, false);

batcher.submitSkinned(key, mesh, boneSkinMatrices, worldMatrix, 0xFFFFFFFF, overlay, packedLight);
GpuInstanceBatcher.FlushStats stats = batcher.flush((batchKey, instances) -> renderCpuFallback(batchKey, instances));

Graphics backends by Minecraft version

Minecraft targets Backend Capabilities
26.3 (Fabric / NeoForge) RenderpearlGpuModelBackend Native Vulkan and OpenGL through Renderpearl GpuDevice / RenderPass, 256-byte aligned uniforms, zero-offset BonePalettePool texel-buffer ring, native drawIndexedIndirect, fullbright EMISSIVE pipelines, and weighted blended OIT (OitPipelineSet)
26.2 (Fabric / NeoForge) GpuModelBackend Native Blaze3D GpuDevice instanced (stepRate = 1), zero-offset TEXEL_BUFFER bone ring skinning, and fullbright EMISSIVE pipelines
26.1.2 / 1.21.1 / 1.20.1 (Fabric / NeoForge / Forge) Gl33GpuModelBackend OpenGL 3.2 Core / 4.3 + ARB_instanced_arrays / ARB_texture_buffer_object (glVertexAttribDivisor, TBO bone palette, indirect draw when available) with explicit capability detection

Automatic _e.png emissive overlays for poly_mesh

For GeckoLib poly_mesh models (entities, held items, and dropped items), KBR Lite automatically resolves a companion <texture>_e.png texture when present and renders it as a fullbright emissive overlay pass across all 10 targets (both GeckoLib 5 and GeckoLib 4). You can also configure or disable the emissive layer explicitly via model metadata or API; missing companion textures incur no extra draw pass and resource reloads (F3+T) refresh the lookup automatically.

Shaderpack coexistence and fallback

When a shader mod such as Iris is active, when OIT is requested on a target without OIT pipelines, or when the graphics backend declines a batch, GpuInstanceBatcher.flush(...) routes those instances to the supplied CPU fallback consumer (SkinnedMeshData.emitAsQuads(...) is available for direct quad emission).

See Animation and model dependencies for backend and resource details.

Clone this wiki locally