Merge pull request #968 from MihailRis/fix-weather-render

fix weather effects render
This commit is contained in:
MihailRis 2026-09-06 19:58:49 +03:00 • committed by GitHub
commit 55a076ed6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View file

@ -13,6 +13,7 @@ uniform vec3 u_fogColor;
uniform float u_fogFactor;
uniform float u_fogCurve;
uniform bool u_alphaClip;
uniform bool u_dithering;
uniform vec3 u_sunDir;
const float BAYER_MATRIX[64] = float[](
@ -35,13 +36,17 @@ void main() {
vec4 texColor = texture(u_texture0, a_texCoord);
float alpha = a_color.a * texColor.a;
// anyway it's any alpha-test alternative required
if (u_alphaClip) {
float bayer = calc_bayer(gl_FragCoord.xy);
if (alpha - bayer < 0.01f) {
if (u_dithering) {
if (u_alphaClip) {
float bayer = calc_bayer(gl_FragCoord.xy);
if (alpha - bayer < 0.01f) {
discard;
}
alpha = 1.0;
} else if (alpha < 0.05f) {
discard;
}
alpha = 1.0;
} else if (alpha < 0.05f) {
} else if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
discard;
}
f_color = a_color * texColor;

View file

@ -144,6 +144,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) {
auto& shader = assets.require<Shader>("entity");
shader.use();
shader.uniform1i("u_alphaClip", false);
shader.uniform1i("u_dithering", 0);
for (const auto& [_, wrapper] : wrappers) {
if (wrapper->dirtySides) {
@ -198,4 +199,4 @@ void BlockWrapsRenderer::clearOrder(const BlockWrapper* const wrapper) {
++it;
}
}
}
}

View file

@ -244,6 +244,7 @@ void WorldRenderer::renderOpaque(
}
entityShader.uniform1i("u_alphaClip", true);
entityShader.uniform1i("u_dithering", 1);
entityShader.uniform1f("u_opacity", 1.0f);
level.entities->render(
assets,
@ -512,6 +513,7 @@ void WorldRenderer::renderWeatherEffects(Camera& camera) {
float one = weather->fall.maxOpacity;
float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
entityShader.uniform1i("u_dithering", 0);
entityShader.uniform1f(
"u_opacity", weather->fall.opaque ? t * t : t
);