Skip to content

Bloom Effect

zomb_676 edited this page Nov 14, 2022 · 13 revisions

Bloom Lava

Shimmer provides some bloom effects based on the post-processing framework. You could add your models with the bloom effect.


How to use

For non-modders, you can add resourcepacks to make the model bloom. There are four ways to add bloom to a model:

  1. Add bloom effects for specific blocks and fluids directly in the config file
{
    "Bloom": [
    {
      "particle": "minecraft:flame"
    },
    {
      "fluid": "minecraft:lava"
    },
    {
      "block": "minecraft:glowstone"
    },
    {
      "block": "minecraft:redstone_wire"
    },
    {
      "block": "minecraft:redstone_lamp",
      "state": {
        "lit": true
      }
    }
  ]
}
  1. Add xxx.png.mcmeta meta files for bloom textures. It will let all models which use this textures will have the bloom effect.
{
    "shimmer": {
        "bloom": true
    }
}
  1. Set texture's tintindex smaller than -100 (exclusive). This quad in the model with the bloom effect.
{
    "ambientocclusion": false,
    "textures": {
        "particle": "block/redstone_dust_dot",
        "line": "block/redstone_dust_dot",
        "overlay": "block/redstone_dust_overlay"
    },
    "elements": [
        {   "from": [ 0, 0.25, 0 ],
            "to": [ 16, 0.25, 16 ],
            "shade": false,
            "faces": {
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#line", "tintindex": -101 },
                "down": { "uv": [ 0, 16, 16, 0 ], "texture": "#line", "tintindex": -101 }
            }
        },
        {   "from": [ 0, 0.25, 0 ],
            "to": [ 16, 0.25, 16 ],
            "shade": false,
            "faces": {
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay" },
                "down": { "uv": [ 0, 16, 16, 0 ], "texture": "#overlay" }
            }
        }
    ]
}
  1. Add the bloom effect for the specific particle via it's json file.
{
    "shimmer": {
        "effect": "bloom_unreal"
    }
}

Java

For blocks, make your quad's tintIndex smaller than -100, or use the texturespirit with a shimmer mcmeta.

You can do this when you need to add bloom effects to render Particle: // for particle bloom effect
PostProcessing.BLOOM_UNREAL.postParticle(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, blockstate), 1, 1, 1, 1, 1, 1);
for particle, this is all

You can do this when you need to add bloom effects to render Entity and BlockEntityRenderer:

// a MultiBufferSource for entity or BlockEntityRenderer, anything rendered in the lambda will be bloomed
PoseStack finalStack = RenderUtils.copyPoseStack(pPoseStack); // we provide a way to copy the poststack
PostProcessing.BLOOM_UNREAL.postEntityForce(bufferSource -> {  //must use the bufferSource provided by us
    VertexConsumer consumer = bufferSource.getBuffer(RenderType.cutout()); //must use the bufferSource provided by us
    renderModel(consumer, finalStack, blockstate, level, blockpos, finalLight);
});
// a MultiBufferSource for entity or BlockEntityRenderer, render during this will support texture/tindex bloom setting  
PoseStack finalStack = RenderUtils.copyPoseStack(pPoseStack); // we provide a way to copy the poststack
PostProcessing.BLOOM_UNREAL.postEntity(bufferSource -> {  //must use the bufferSource provided by us
    VertexConsumer consumer = bufferSource.getBuffer(RenderType.cutout()); //must use the bufferSource provided by us
    renderModel(consumer, finalStack, blockstate, level, blockpos, finalLight);
});

you can also call PostProcessing#forceBloomBlock(Runnable) and PostProcessing.forceBloomFluid(Runnable) in postEntity to force bloom some block
also, PostProcessing#setupBloom(BlockState blockState, FluidState fluidState) is the setting query version of forceBloomBlock/Fluid
what's more, the BakedQuad will have a new field called isBloom added by shimmer via mixin, you can control that field
for the filtered version, the render type you use should be supported by the shimmer, you can see them in the log when launching the game

after submitting all that you want to render, you need to call PostProcessing.BLOOM_UNREAL.renderEntityPost to do actual render stuff

Clone this wiki locally