sp614x / optifine

1.77k stars 420 forks source link

[shader] atlasSize uniform turns ivec2(0) on some entities #7551

Open GeForceLegend opened 9 months ago

GeForceLegend commented 9 months ago

Description of Issue

Some entities' atlasSize uniform turns ivec2(0) even though they have their textures.

Steps to Reproduce

Using the template shader pack from shaderLABS for edit: https://cdn.discordapp.com/attachments/237199950235041794/825483993951633438/base.zip Editing gbuffers_entities.fsh:

#version 120

uniform sampler2D lightmap;
uniform sampler2D texture;
uniform vec4 entityColor;

varying vec2 lmcoord;
varying vec2 texcoord;
varying vec4 glcolor;

uniform ivec2 atlasSize;

void main() {
    vec4 color = texture2D(texture, texcoord) * glcolor;
    color.rgb = mix(color.rgb, entityColor.rgb, entityColor.a);
    color *= texture2D(lightmap, lmcoord);

/* DRAWBUFFERS:0 */
    gl_FragData[0] = color; //gcolor
    gl_FragData[0].rgb = vec3(step(vec2(0.5), atlasSize), 0.0);
}

if atlasSize is working (x and y both >0), the entity should be yellow. And this is what we get: item frames and dropped items are working well, but boats are black which means their atlasSize is ivec2(0). Lots of other entities are black too. 2023-09-17_11 17 36

OptiFine Version

1.20.1 H5

Installation Method

Standalone

F3 Debug Screenshot

Provided above.

fayer3 commented 6 months ago

that is intended afaik. atlasSize is only set when the block atlas is bound so only entities that have their texture on the block atlas have it set

uniform ivec2 atlasSize; texture atlas size (only set when the atlas texture is bound)

GeForceLegend commented 6 months ago

that is intended afaik. atlasSize is only set when the block atlas is bound so only entities that have their texture on the block atlas have it set

uniform ivec2 atlasSize; texture atlas size (only set when the atlas texture is bound)

Some entities even with their textures have wrong atlasSize, as I described, boats, maybe some more, at that point I tested this.

GeForceLegend commented 6 months ago

I'm afraid that All entites that have their standalone texture but not using block atlas, excepting block entites, have this issue. Tested just now with Optifine 1.20.1 I6 Pre6, not sure if this still exists in 1.20.4. Tested, this issue is still in 1.20.4, and only seems to affect the "real entities"? Dropped items with standalone entity textures like chests working fine. And, it's very interesting that the chest in chest minecart is working fine, but the minecart itself sucks.

fayer3 commented 6 months ago

hm okay then it's weird, chests shouldn't work, they are not on the block atlas

maybe a legacy thing, since they were once on the block atlas, iirc

GeForceLegend commented 6 months ago

All block entites' atlasSize working well, including the latest decorated_pot (128 64) and hanging_sign (256 256). That's why I'm guessing there is something wrong with entities' atlasSize, but not some block entities wrongly get atlasSize.