-
Notifications
You must be signed in to change notification settings - Fork 4
How to Add Compatibility with HDR Mod In 26.2
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
MainTargettoGpuFormat.RGBA16_FLOAT; - Upgraded
entityOutlineTargetinLevelRenderertoGpuFormat.RGBA16_FLOAT; - Upgraded
RenderTargetDescriptorinPostChaintoGpuFormat.RGBA16_FLOAT; -
Upgraded "UI items atlas" texture in;GuiItemAtlastoGpuFormat.RGBA16_FLOAT - Modified the format of
DEFAULTColorTargetStateand one-element constructor ofColorTargetStateakanew ColorTargetState(final BlendFunction blendFunction)toGpuFormat.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 aColorTargetStatewith a format ofGpuFormat.RGBA16_FLOAT.
- As a result, all render pipelines in vanilla
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 vanillaRenderPipelinesshould have a format ofGpuFormat.RGBA16_FLOATinstead ofGpuFormat.RGBA8_UNORM, or you should not directly reuse render pipeline in vanillaRenderPipelines, instead you should manually create one explicitly set format toGpuFormat.RGBA8_UNORM;Any custom render pipelines that intend to bind the above upgraded target as color attachments should haveColorTargetStatewith a format ofGpuFormat.RGBA16_FLOAT. If you do not explicitly set format toGpuFormat.RGBA8_UNORMpreviously, nothing should be done.-
A good practice is to separate theAfter 3.0.0-alpha2, HDR Mod will automatically recreate pipeline against matched format if its format ofRenderPipelinewith internal RGBA8 texture as target (manually specify RGBA8 format) andRenderPipelinewith vanilla target (do not manually specify RGBA8 format).ColorTargetStatedoes not match current attachment. So in most cases you don't need to do anything to keep compatibility.