Skip to content

Commit d6c6526

Browse files
jellysquid3ThatMG393
authored andcommitted
Fix precision issues in cloud rendering at far distances
1 parent 8caad67 commit d6c6526

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ public void render(Camera camera,
9898
var renderMode = Minecraft.getInstance().options.getCloudsType();
9999

100100
// Translation of the clouds texture in world-space
101-
float worldX = (float) (cameraPos.x + ((ticks + tickDelta) * 0.03F));
102-
float worldZ = (float) (cameraPos.z + 3.96F);
101+
double worldX = (cameraPos.x + ((ticks + tickDelta) * 0.03D));
102+
double worldZ = (cameraPos.z + 3.96D);
103103

104-
float textureWidth = this.textureData.width * CLOUD_WIDTH;
105-
float textureHeight = this.textureData.height * CLOUD_WIDTH;
104+
double textureWidth = this.textureData.width * CLOUD_WIDTH;
105+
double textureHeight = this.textureData.height * CLOUD_WIDTH;
106106
worldX -= Mth.floor(worldX / textureWidth) * textureWidth;
107107
worldZ -= Mth.floor(worldZ / textureHeight) * textureHeight;
108108

@@ -139,9 +139,9 @@ public void render(Camera camera,
139139
}
140140

141141
// Apply world->view transform
142-
final float viewPosX = (worldX - (cellX * CLOUD_WIDTH));
142+
final float viewPosX = (float) (worldX - (cellX * CLOUD_WIDTH));
143143
final float viewPosY = (float) cameraPos.y() - height;
144-
final float viewPosZ = (worldZ - (cellZ * CLOUD_WIDTH));
144+
final float viewPosZ = (float) (worldZ - (cellZ * CLOUD_WIDTH));
145145

146146
Matrix4f modelViewMatrix = new Matrix4f(modelView);
147147
modelViewMatrix.translate(-viewPosX, -viewPosY, -viewPosZ);

0 commit comments

Comments
 (0)