Skip to content

Commit

Permalink
Round texture UVs to a half-texel before encoding
Browse files Browse the repository at this point in the history
This fixes problems with torches and some other blocks when
the texture atlas is large.
  • Loading branch information
jellysquid3 committed Dec 20, 2023
1 parent 9b7d4c3 commit 1d39fdc
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1d39fdc

Please sign in to comment.