Skip to content

Commit

Permalink
Fix precision issues in cloud rendering at far distances
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Nov 24, 2024
1 parent 990cf64 commit 53d69f3
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public void render(Camera camera,
var renderMode = Minecraft.getInstance().options.getCloudsType();

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

float textureWidth = this.textureData.width * CLOUD_WIDTH;
float textureHeight = this.textureData.height * CLOUD_WIDTH;
double textureWidth = this.textureData.width * CLOUD_WIDTH;
double textureHeight = this.textureData.height * CLOUD_WIDTH;
worldX -= Mth.floor(worldX / textureWidth) * textureWidth;
worldZ -= Mth.floor(worldZ / textureHeight) * textureHeight;

Expand Down Expand Up @@ -139,9 +139,9 @@ public void render(Camera camera,
}

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

Matrix4f modelViewMatrix = new Matrix4f(modelView);
modelViewMatrix.translate(-viewPosX, -viewPosY, -viewPosZ);
Expand Down

0 comments on commit 53d69f3

Please sign in to comment.