Sodium

Sodium

44M Downloads

Alpha of certain block texture is 1.0 / 255.0 in atlas while it's 0.0 in raw texture

GeForceLegend opened this issue ยท 5 comments

commented

Bug Description

Alpha channel of certain block texture has a strange 1.0 / 255.0 value in atlas texture, even though in raw texture it's alpha is 0.0. This may affect transparent object detection in shaders, or something more.

Reproduction Steps

  1. Launch game with only sodium-fabric-0.6.0-beta.1+mc1.21.jar mod. I'll use vanilla resourcepack shaders but not OF shaders to show this issue to prevent Iris' influence.
  2. Using this resourcepack. It modified vanilla entity shaders, to let pixels with 1.0 / 255.0 alpha turns red.
    SodiumAlphaTest.zip
  3. Full transparent part of most leaves in non-block form (in GUI, held, or dropped on ground, etc) in vanilla turns red, meaning their alpha is 1.0 / 255.0. Maybe there are more blocks affected.
    20240915-102232

Log File

Nothing useful in log. Only used Sodium mod and provided resourcepack.

Crash Report

No crash.

commented

This does NOT match vanilla behavior, as those part in vanilla leaves are pure dark when graphics is set to fast. It doesn't make any sense replacing fully transparent pixels of leaves with avg color.

commented

The problem is that most resource packs (including Minecraft itself) are created with image editors that discard the color values of fully transparent pixels. This causes problems with mip-mapping, since when the image is downscaled, these pixels (which are usually #000000) get blended with their neighbors.

For the example of leaf blocks, this makes them appear too dark in-game, when the texture itself is much brighter. Additionally, you can notice that grass blocks when viewed from the side are blackened across the edges.

I understand that we are deviating from the behavior of Minecraft, but that is intentional. We would prefer to fix the graphical bugs which are caused by this problem, rather than maintain exact compatibility with core shaders.

commented

There is more information that can be read here about the problem.

commented

This is not a bug, and core shaders are not supported.

Sodium interprets fully-transparent pixels as having no color data, and replaces them with an averaged color of the non-transparent pixels. For certain blocks, we replaced the textures so that empty parts of the texture are not quite fully transparent, so that color values are not replaced.

commented

So does it possible to save the range of leave textures, and edit them after merging into atlas texture? This can make alpha channel stay in 0.0 but not 1.0 / 255.0