Skip to content

Rendering Integration >=26.1 ​

ALRendering ​

Mod entry point main class, registered via @Mod and @EventBusSubscriber.

Initialization and Events ​

EventHandling
RenderFrameEvent.PrebloomPostEffect.beginFrame()
RenderLevelStageEvent.AfterLevelbloomPostEffect.process(modelViewMatrix, featureRenderDispatcher)
RegisterPipelineModifiersEventRegister REDIRECT_TO_BLOOM modifier
java
// Get the bloom instance
BloomPostEffect bloom = ALRendering.getBloomPostEffect();

Pipeline Creation ​

ALRendering.createPipelines() is called in the MinecraftMixin construction end callback to initialize the bloom instance.

Shaders and Pipelines ​

Shader Files ​

FileTypePurpose
blit.vshVertexFull-screen quad transform, outputs UV
blur.fshFragment7-weight Gaussian blur (direction + step length)
apply_bloom.fshFragmentBlend bloom onto the game framebuffer by intensity
down_sample.fshFragmentAverage 4 pixels for downsampling
up_sample.fshFragment5×5 Gaussian kernel upsample, blend with previous frame
util.glslUtilitysaturate(), toneMap() helper functions

Pipeline Registration (ALRPipelines) ​

4 pipelines based on the POST_PASS fragment:

PipelinePurpose
BLURGaussian blur
APPLY_BLOOMBloom blend to framebuffer
DOWNSAMPLEDownsampling
UPSAMPLEUpsampling

The base fragment POST_PASS uses blit.vsh, binds Transforms UBO and DiffuseSampler, and disables face culling.

Mixin ​

MinecraftMixin ​

  • Calls ALRendering.createPipelines() at construction end to initialize the bloom instance
  • Restores bloom texture size on window resize

GuiRendererMixin ​

  • Tracks the GuiElementRenderState corresponding to each GUI draw element
  • When an element implements LibGuiElementRenderState, binds the UBO slices returned by its bufferSlices() to the RenderPass before drawing

State Interfaces ​

LibGuiElementRenderState ​

Extends GuiElementRenderState, allowing GUI elements to inject custom Uniforms.

java
public interface LibGuiElementRenderState extends GuiElementRenderState {
    // Returns the UBO buffer slices to bind
    Map<String, GpuBufferSlice> bufferSlices();
}

LibQuadGuiElementRenderState ​

Provides convenient viewport calculation and vertex construction for quad elements:

java
public interface LibQuadGuiElementRenderState extends LibGuiElementRenderState {
    AABB getBounds();           // Viewport bounding box
    void buildVertices(...);    // Vertex construction
}

Testing and Debugging ​

ALRTest provides examples (e.g., rendering items with bloom):

java
// Enable debug mode: add JVM property
// -Danvillib.rendering.debugMode=true
java
ALRTest.renderCarrotBloomed(); // Render a glowing carrot

Custom GUI Element UBO Injection ​

java
public class MyGuiElement implements LibQuadGuiElementRenderState {
    @Override
    public Map<String, GpuBufferSlice> bufferSlices() {
        Map<String, GpuBufferSlice> slices = new HashMap<>();
        slices.put("MyUniform", myUniformBuffer);
        return slices;
    }
}

Released under the CC-BY-NC-SA 4.0 License.