From 1d39fdcaa0e8b31714f248bdeca07dd57886309c Mon Sep 17 00:00:00 2001 From: JellySquid Date: Tue, 19 Dec 2023 22:40:58 -0600 Subject: [PATCH] Round texture UVs to a half-texel before encoding This fixes problems with torches and some other blocks when the texture atlas is large. --- .../render/chunk/vertex/format/impl/CompactChunkVertex.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java index 5bda76dacb..b0f1a486d1 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java @@ -97,8 +97,8 @@ private static int encodeLight(int light) { private int encodeTexture(float u, float v) { // Transform the normalized coordinates back into half-texel coordinates, and then scale it // to the full addressing range the shader uses. - var scaledU = (int) ((u * this.atlasWidth) * this.textureScaleU); - var scaledV = (int) ((v * this.atlasHeight) * this.textureScaleV); + var scaledU = Math.round(u * this.atlasWidth) * this.textureScaleU; + var scaledV = Math.round(v * this.atlasHeight) * this.textureScaleV; return ((scaledU & 0xFFFF) << 0) | ((scaledV & 0xFFFF) << 16); }