Skip to content

Bind the overlay texture for pipelines that don't declare Sampler1 - #3440

Open
tmy7533018 wants to merge 1 commit into
IrisShaders:26.3from
tmy7533018:fix/armor-overlay-sampler
Open

tmy7533018 wants to merge 1 commit into
IrisShaders:26.3from
tmy7533018:fix/armor-overlay-sampler

Conversation

@tmy7533018

Copy link
Copy Markdown

Problem

On 26.3 with a shader pack, some entity equipment layers render solid black: happy ghast harnesses, trader llama carpets, and horse armor (seen on a zombie horse). Which layers are affected changes from launch to launch, but stays the same for the whole session. Disabling shaders fixes it. It happens with Complementary Unbound and with Bliss, and reproduces with only Fabric API, Sodium and Iris installed.

This may be what some reports in #3376 describe as "blacked out armors".

Cause

ARMOR_CUTOUT_NO_CULL and ARMOR_CUTOUT_NO_CULL_GLINT set the NO_OVERLAY define and don't declare Sampler1, unlike ENTITY_CUTOUT. Iris still treats these programs as having an overlay, because the vertex format contains UV1, so iris_overlay is an external sampler on unit 1 and EntityPatcher computes entityColor with texelFetch(iris_overlay, iris_UV1, 0).

Vanilla never binds unit 1 for these pipelines, so the shader reads whatever an earlier draw left there. If that happens to be the overlay texture, (0, 10) (NO_OVERLAY) is opaque and entityColor is zero. If it is any other texture, the fetch returns transparent black, entityColor becomes (0, 0, 0, 1), and packs that do mix(color.rgb, entityColor.rgb, entityColor.a) output black. The draw order depends on hashing, which is why the result differs per launch.

Fix

In ExtendedShader.iris$setupState, when the program expects an overlay but the vanilla pipeline's uniforms don't include Sampler1, bind the vanilla overlay texture to unit 1. Armor is submitted with OverlayTexture.NO_OVERLAY, so entityColor stays zero and armor looks the same as without shaders. Pipelines that declare Sampler1 are untouched, and vanilla marks every uniform dirty on a pipeline change, so the binding doesn't leak into later entity draws.

Binding the white pixel instead doesn't work: it is 1x1, so (0, 10) is out of range and every armor layer turns black.

Testing

  • Minecraft 26.3, Fabric API 0.164.0, Sodium 0.9.2, Iris 26.3 at 671a5c8 with this change
  • Superflat test world with a happy ghast (light_gray_harness), a zombie horse and horses with diamond horse armor, and a llama with a carpet, viewed from fixed camera positions over repeated launches
  • A probe pack that colors fragments with entityColor.a > 0.02: before the change, 3 of 4 launches showed it on armor or harnesses; after, 0 of 8
  • Complementary Unbound r5.9.3 with default settings: before, black harnesses or armor in about half the launches; after, 0 of 4
  • Hurt flash still shows on regular entities
  • Also checked in my own world with a larger mod set
  • AMD RX 9070 XT, Mesa 26.2.4, Linux

The investigation and this patch were done with Claude Code (an AI assistant) on my machine. I tested the result in my own world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant