Skip to main content
Version: 26.1

Shaders

PulseLib uses two triangle-rendering paths. Normal block-entity, entity, and item rendering is queued and instanced through PRenderQueue. Direct PBakedBone.instantDraw(...) calls use the instant path. Both consume the same baked POSITION_TEX_NORMAL mesh data, but receive per-draw data differently.

PulseLib registers its immutable RenderPipeline instances through NeoForge's RegisterRenderPipelinesEvent and Fabric client initialization. Both loaders register the GUI picture-in-picture adapter as well. Consumers should choose a render type from PRenderTypes.RenderTypeProvider, rather than registering or binding a built-in pipeline directly. Every current core program uses GLSL version 330.

Built-in shader paths​

PathShader sourcesUsed by
Queuedtriangles.vsh and triangles.fshPBlockRenderer, PEntityRenderer, and PItemRenderer, including GUI items
Instanttriangles_instant.vsh and triangles_instant.fshPBakedBone.instantDraw(...) and PLibHelper.renderModelInGui(...)
OITtriangles_oit.fsh, triangles_oit_depth.fsh, and triangles_oit_depth_peel.fshInternal translucent queued rendering
OIT compositeoit_composite.vsh and oit_composite.fshInternal composition of translucent layers

The queued and instant paths select their solid, cutout, translucent, and emissive variants through pipeline defines. FORCE_OPAQUE forces output alpha to one, ALPHA_CUTOUT discards texels below 0.1, and EMISSIVE bypasses directional lighting and the lightmap while retaining texture alpha, tint, and overlay.

Render types​

Use these public factories as renderer inputs:

Material resultQueued rendererDirect instantDraw
OpaquetrianglesSolidtrianglesInstantSolid
CutouttrianglesCutouttrianglesInstantCutout
TranslucenttrianglesTranslucenttrianglesInstantTranslucent
EmissivetrianglesEmissiveSolid, trianglesEmissiveCutout, trianglesEmissiveTranslucentmatching trianglesInstantEmissive... variant

Use trianglesInstantTranslucent for direct drawing. A PItemRenderer remains on the queued path even in a GUI. PAlphaMode maps to the queued solid, cutout, and translucent variants, while forInstantAlphaMode(...) selects the instant equivalents. See Resources for texture alpha classification.

Vertex and per-draw contract​

All PulseLib mesh shaders use PRenderTypes.VertexFormatProvider.POSITION_TEX_NORMAL with VertexFormat.Mode.TRIANGLES:

Attribute locationValue
0Position — local vertex position
1UV0 — UV in the PulseLib runtime atlas
2Normal — local packed normal
3Unused

The queued path additionally reads one 96-byte instance record:

Attribute locationsValue
4–6InstanceRow0..2 — affine model transform
7InstanceColor — normalized ARGB tint
8InstanceLight — block and sky light coordinates
9InstanceOverlay — overlay coordinates
10InstanceDeformer — operation offset, value offset, and operation count

The instant path has no instance record. It receives colour, light, overlay, and deformer offsets/count through the ColorOverlay uniform buffer. Both paths receive the actual deformer streams through DeformerOperations and DeformerValues, receive Minecraft's dynamic transforms, use the PulseLib runtime atlas as Sampler0, and use the overlay and lightmap samplers when the selected variant requires them.

GPU deformers​

deformers.glsl applies the compiled operation stack in local mesh space before the model transform. It reads DeformerOperations and DeformerValues texel buffers and updates normals from the deformation Jacobian. Both queued and instant paths use this include; the mesh can also be subdivided before submission. Built-in supported stacks use shader deformation; unsupported/custom prepared operations use CPU-deformed dynamic geometry through the same backend.

The shader currently supports up to eight operations per submitted mesh. This is the renderer's internal data contract. A custom pipeline that receives PulseLib geometry must preserve the vertex format, queued attribute locations, and deformer-buffer layout, or it will not render queued meshes correctly.

Translucency and OIT​

trianglesTranslucent and trianglesEmissiveTranslucent support the internal OIT path. The submission must also select PTransparencyMode.OIT, the target must have usable depth, and the driver must support independent per-target blending. PulseLib depth-peels four layers, accumulates weighted colour/revealage, and composites them according to the active native transparency route.

PTransparencyMode.ORDINARY keeps the same material and uses sorted alpha blending. Queue overloads without a policy default supported built-in queued translucent types to OIT; callers such as living attachments may explicitly request ordinary alpha. Custom translucent types are not automatically OIT-enabled. Application code selects a normal material and policy; it does not bind internal OIT pass shaders.

For render stages, queue batching, and the normal renderer entry points, see Render types and queue.