Skip to content

How to Add Compatibility with HDR Mod In 26.2

rrtt217 edited this page Jul 4, 2026 · 6 revisions

Background

Before 26.2 generally mod devs don't need to do anything to make other mods compatible with HDR Mod.

In 26.2, Mojang added ColorTargetState as a property for the pipeline, probably in order to implement MRT (Multiple Render Targets). ColorTargetState defines the blending function, write mask and the GpuFormat of EVERY color attachment which will be specified in the creation of an RenderPass and will be validated when RenderPass.setPipeline(renderPipeline) is called.

If the validation does not pass, the game will throw an error:

java.lang.IllegalStateException: Render pass color attachment <x> format doesn't match pipeline format.

and crash.

In order to properly implement HDR, HDR Mod need to upgrade the main render target (which is the render target of most vanilla renderers, and also the render target of program "final" in Iris) and modify the pipeline accordingly. More specifically, these are what HDR Mod has done:

  • Upgraded MainTarget to GpuFormat.RGBA16_FLOAT;
  • Upgraded entityOutlineTarget in LevelRenderer to GpuFormat.RGBA16_FLOAT;
  • Upgraded RenderTargetDescriptor in PostChain to GpuFormat.RGBA16_FLOAT;
  • Upgraded "UI items atlas" texture in GuiItemAtlas to GpuFormat.RGBA16_FLOAT;
  • Modified the format of DEFAULT ColorTargetState and one-element constructor of ColorTargetState aka new ColorTargetState(final BlendFunction blendFunction) to GpuFormat.RGBA16_FLOAT;
    • As a result, all render pipelines in vanilla RenderPipelines (except ANIMATE_SPRITE_* and LIGHTMAP, which I manually set to GpuFormat.RGBA8_UNORM) has been set to a ColorTargetState with a format of GpuFormat.RGBA16_FLOAT.

What Should Be Done to Add Compatibility

After 3.0.0-alpha2, HDR Mod will automatically recreate pipeline against matched format if its format of ColorTargetState does not match current attachment. So in most cases you don't need to do anything to keep compatibility.

Generally:

  • Any custom targets that need to be a color attachment of vanilla RenderPipelines should have a format of GpuFormat.RGBA16_FLOAT instead of GpuFormat.RGBA8_UNORM, or you should not directly reuse render pipeline in vanilla RenderPipelines, instead you should manually create one explicitly set format to GpuFormat.RGBA8_UNORM;
  • Any custom render pipelines that intend to bind the above upgraded target as color attachments should have ColorTargetState with a format of GpuFormat.RGBA16_FLOAT. If you do not explicitly set format to GpuFormat.RGBA8_UNORM previously, nothing should be done.
  • A good practice is to separate the RenderPipeline with internal RGBA8 texture as target (manually specify RGBA8 format) and RenderPipeline with vanilla target (do not manually specify RGBA8 format). After 3.0.0-alpha2, HDR Mod will automatically recreate pipeline against matched format if its format of ColorTargetState does not match current attachment. So in most cases you don't need to do anything to keep compatibility.

Clone this wiki locally