From 6244dc28489ab1131602259a99e0190d3dae3bc6 Mon Sep 17 00:00:00 2001 From: FoundationGames <43485105+FoundationGames@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:07:39 -0700 Subject: [PATCH] Tweak LOD cable texture stretching --- .../phonos/client/render/CableRenderer.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/foundationgames/phonos/client/render/CableRenderer.java b/src/main/java/io/github/foundationgames/phonos/client/render/CableRenderer.java index 74a71f8..99ebf54 100644 --- a/src/main/java/io/github/foundationgames/phonos/client/render/CableRenderer.java +++ b/src/main/java/io/github/foundationgames/phonos/client/render/CableRenderer.java @@ -93,7 +93,9 @@ public static void renderConnection(PhonosClientConfig config, World world, Cabl float g = conn.color != null ? conn.color.getColorComponents()[1] : 1; float b = conn.color != null ? conn.color.getColorComponents()[2] : 1; float length = cableStPt.distance(cableEnPt); - int segments = Math.max((int) Math.ceil(4 * length * config.cableLODNearDetail), 1); + + double detail = config.cableLODNearDetail; + int segments = Math.max((int) Math.ceil(4 * length * detail), 1); if (config.cableLODs) { float cx = (cableStPt.x + cableEnPt.x) * 0.5f; @@ -103,11 +105,13 @@ public static void renderConnection(PhonosClientConfig config, World world, Cabl double sqDist = MinecraftClient.getInstance().gameRenderer.getCamera().getPos() .squaredDistanceTo(cx, cy, cz); double delta = MathHelper.clamp(sqDist / (length * length * 4), 0, 1); - double detail = MathHelper.lerp(delta, config.cableLODNearDetail, config.cableLODFarDetail); + detail = MathHelper.lerp(delta, config.cableLODNearDetail, config.cableLODFarDetail); segments = Math.max((int) Math.ceil(4 * length * detail), Math.min(3, segments)); } + final float texUWid = (float) (0.25 / detail); + cableRotAxis.set(cableEnPt.z - cableStPt.z, 0, cableEnPt.x - cableStPt.x); float cablePitch = (float) Math.atan2(cableEnPt.y - cableStPt.y, cableRotAxis.length()); @@ -159,13 +163,13 @@ public static void renderConnection(PhonosClientConfig config, World world, Cabl var nml = cableNormal[i]; buffer.vertex(currCableStart[i].x, currCableStart[i].y, currCableStart[i].z).color(r, g, b, 1) - .texture(0.25f, 0.3125f + vOffset2).overlay(overlay).light(segStartLight).normal(nml.x, nml.y, nml.z).next(); + .texture(texUWid, 0.3125f + vOffset2).overlay(overlay).light(segStartLight).normal(nml.x, nml.y, nml.z).next(); buffer.vertex(currCableEnd[i].x, currCableEnd[i].y, currCableEnd[i].z).color(r, g, b, 1) .texture(0, 0.3125f + vOffset2).overlay(overlay).light(segEndLight).normal(nml.x, nml.y, nml.z).next(); buffer.vertex(currCableEnd[next].x, currCableEnd[next].y, currCableEnd[next].z).color(r, g, b, 1) .texture(0, 0.375f + vOffset2).overlay(overlay).light(segEndLight).normal(nml.x, nml.y, nml.z).next(); buffer.vertex(currCableStart[next].x, currCableStart[next].y, currCableStart[next].z).color(r, g, b, 1) - .texture(0.25f, 0.375f + vOffset2).overlay(overlay).light(segStartLight).normal(nml.x, nml.y, nml.z).next(); + .texture(texUWid, 0.375f + vOffset2).overlay(overlay).light(segStartLight).normal(nml.x, nml.y, nml.z).next(); } }