sp614x / optifine

1.8k stars 418 forks source link

uniform atlasSize is broken in deferred/composite #6209

Open GeForceLegend opened 3 years ago

GeForceLegend commented 3 years ago

Description of Issue

uniform atlasSize is broken when held item is not transparent in deferred/composite

Steps to Reproduce

This is the example code : (composite.fsh)

#version 460

layout (location = 0) out vec4 fragColor0;

in vec2 texcoord;

uniform float viewWidth;
uniform float viewHeight;
uniform ivec2 atlasSize;
uniform sampler2D colortex1;

void main()
{
    vec2 screenSize = vec2(viewWidth, viewHeight);
    ivec2 trueAtlasSize = textureSize(colortex1, 0);
    vec2 atlasCoord = screenSize / atlasSize * texcoord;
    // vec2 atlasCoord = screenSize / trueAtlasSize * texcoord;
    fragColor0 = texture2D(colortex1, atlasCoord);
}

colortex1 is set to minecraft:textures/atlas/blocks.png by shaders.properties

while using "trueAtlasSize" that generated by textureSize function, the output will be like this:

2021-09-02_16 28 53

while using the atlasSize uniform with gbuffers_hand_water program not used (no transparent hand held item, including hide the held item by F1), the output will be extremely strange:

2021-09-02_16 29 15

but if there is a hand held transparent item, the atlasSize uniform then will work fine

2021-09-02_16 29 28

OptiFine Version

1.17.1 G9, but this bug may have appeared for a long time after 1.14 (1.14 is fine), and this is the bug that caused continuum rt need a transparent held item to rendering correctly, and this issue starts from 1.16 or 1.15.

Installation Method

standalone

Log Files/Crash Reports

Nothing useful in log and no crashes

GeForceLegend commented 2 days ago

Still exist in 1.21.1 J1. If this is work as intended (atlasSize is not set to the size of main block/item atlas in composite passes), please close it.