diff --git a/src/main/java/rs117/hd/HdPlugin.java b/src/main/java/rs117/hd/HdPlugin.java index 044e1ff81f..2f9f8c8e09 100644 --- a/src/main/java/rs117/hd/HdPlugin.java +++ b/src/main/java/rs117/hd/HdPlugin.java @@ -77,6 +77,7 @@ import org.lwjgl.system.Configuration; import rs117.hd.config.ColorFilter; import rs117.hd.config.DynamicLights; +import rs117.hd.config.GroundBlending; import rs117.hd.config.SeasonalHemisphere; import rs117.hd.config.SeasonalTheme; import rs117.hd.config.ShadingMode; @@ -387,6 +388,8 @@ public class HdPlugin extends Plugin { // Configs used frequently enough to be worth caching public boolean configGroundTextures; public boolean configGroundBlending; + public boolean configGroundBlendingColors; + public boolean configGroundBlendingTextures; public boolean configModelTextures; public boolean configLegacyTzHaarReskin; public boolean configProjectileLights; @@ -1592,7 +1595,10 @@ private void updateCachedConfigs() { configShadowsEnabled = configShadowMode != ShadowMode.OFF; configRoofShadows = config.roofShadows(); configGroundTextures = config.groundTextures(); - configGroundBlending = config.groundBlending(); + var groundBlending = config.groundBlending(); + configGroundBlending = groundBlending != GroundBlending.OFF; + configGroundBlendingColors = groundBlending.colors; + configGroundBlendingTextures = groundBlending.textures; configModelTextures = config.modelTextures(); configLegacyTzHaarReskin = config.legacyTzHaarReskin(); configProjectileLights = config.projectileLights(); diff --git a/src/main/java/rs117/hd/HdPluginConfig.java b/src/main/java/rs117/hd/HdPluginConfig.java index 6541df291e..67b9e1f5e7 100644 --- a/src/main/java/rs117/hd/HdPluginConfig.java +++ b/src/main/java/rs117/hd/HdPluginConfig.java @@ -39,6 +39,7 @@ import rs117.hd.config.DefaultSkyColor; import rs117.hd.config.DynamicLights; import rs117.hd.config.FogDepthMode; +import rs117.hd.config.GroundBlending; import rs117.hd.config.InfernalCape; import rs117.hd.config.Saturation; import rs117.hd.config.SceneScalingMode; @@ -718,16 +719,22 @@ default TextureResolution textureResolution() return TextureResolution.RES_256; } - String KEY_GROUND_BLENDING = "groundBlending"; + String KEY_GROUND_BLENDING = "groundBlendingv2"; @ConfigItem( keyName = KEY_GROUND_BLENDING, name = "Ground Blending", - description = "Controls whether ground tiles should blend into each other, or have distinct edges.", + description = + "Controls whether ground tiles should blend into each other, or have distinct edges.
" + + "When set to 'Textures only', textures may blend between tiles, but not their colors.", position = 10, section = environmentSettings ) - default boolean groundBlending() + default GroundBlending groundBlending() { + return groundBlendingv1() ? GroundBlending.ON : GroundBlending.TEXTURES_ONLY; + } + @ConfigItem(keyName = "groundBlending", hidden = true, name = "", description = "") + default boolean groundBlendingv1() { return true; } diff --git a/src/main/java/rs117/hd/config/GroundBlending.java b/src/main/java/rs117/hd/config/GroundBlending.java new file mode 100644 index 0000000000..b2a811787e --- /dev/null +++ b/src/main/java/rs117/hd/config/GroundBlending.java @@ -0,0 +1,19 @@ +package rs117.hd.config; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum GroundBlending { + ON("On", true, true), + TEXTURES_ONLY("Textures only", false, true), + OFF("Off", false, false); + + private final String name; + public final boolean colors; + public final boolean textures; + + @Override + public String toString() { + return name; + } +} diff --git a/src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java b/src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java index f5423eddf0..509a9bedc8 100644 --- a/src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java +++ b/src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java @@ -659,16 +659,19 @@ private int[] uploadHDTilePaintSurface( neNormals = sceneContext.vertexTerrainNormals.getOrDefault(neVertexKey, neNormals); nwNormals = sceneContext.vertexTerrainNormals.getOrDefault(nwVertexKey, nwNormals); - boolean useBlendedMaterialAndColor = + boolean allowBlending = plugin.configGroundBlending && textureId == -1 && !proceduralGenerator.useDefaultColor(tile, override); + boolean blendColors = plugin.configGroundBlendingColors && allowBlending; + boolean blendTextures = plugin.configGroundBlendingTextures && allowBlending; + GroundMaterial groundMaterial = null; if (override != TileOverride.NONE) { groundMaterial = override.groundMaterial; uvOrientation = override.uvOrientation; uvScale = override.uvScale; - if (!useBlendedMaterialAndColor) { + if (!blendColors) { swColor = override.modifyColor(swColor); seColor = override.modifyColor(seColor); nwColor = override.modifyColor(nwColor); @@ -683,24 +686,25 @@ private int[] uploadHDTilePaintSurface( groundMaterial = override.groundMaterial; } - if (useBlendedMaterialAndColor) { - // get the vertices' colors and textures from hashmaps + if (blendColors) { swColor = sceneContext.vertexTerrainColor.getOrDefault(swVertexKey, swColor); seColor = sceneContext.vertexTerrainColor.getOrDefault(seVertexKey, seColor); neColor = sceneContext.vertexTerrainColor.getOrDefault(neVertexKey, neColor); nwColor = sceneContext.vertexTerrainColor.getOrDefault(nwVertexKey, nwColor); + } - if (plugin.configGroundTextures) { + if (plugin.configGroundTextures) { + if (blendTextures) { swMaterial = sceneContext.vertexTerrainTexture.getOrDefault(swVertexKey, swMaterial); seMaterial = sceneContext.vertexTerrainTexture.getOrDefault(seVertexKey, seMaterial); neMaterial = sceneContext.vertexTerrainTexture.getOrDefault(neVertexKey, neMaterial); nwMaterial = sceneContext.vertexTerrainTexture.getOrDefault(nwVertexKey, nwMaterial); + } else if (groundMaterial != null) { + swMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1], worldPos[2]); + seMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1], worldPos[2]); + nwMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1] + 1, worldPos[2]); + neMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1] + 1, worldPos[2]); } - } else if (plugin.configGroundTextures && groundMaterial != null) { - swMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1], worldPos[2]); - seMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1], worldPos[2]); - nwMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1] + 1, worldPos[2]); - neMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1] + 1, worldPos[2]); } } else @@ -1016,15 +1020,18 @@ private int[] uploadHDTileModelSurface( GroundMaterial groundMaterial = null; - boolean useBlendedMaterialAndColor = + boolean allowBlending = plugin.configGroundBlending && textureId == -1 && !(isOverlay && proceduralGenerator.useDefaultColor(tile, override)); + boolean blendColors = plugin.configGroundBlendingColors && allowBlending; + boolean blendTextures = plugin.configGroundBlendingTextures && allowBlending; + if (override != TileOverride.NONE) { groundMaterial = override.groundMaterial; uvOrientation = override.uvOrientation; uvScale = override.uvScale; - if (!useBlendedMaterialAndColor) { + if (!blendColors) { colorA = override.modifyColor(colorA); colorB = override.modifyColor(colorB); colorC = override.modifyColor(colorC); @@ -1034,33 +1041,34 @@ private int[] uploadHDTileModelSurface( groundMaterial = override.groundMaterial; } - if (useBlendedMaterialAndColor) { - // get the vertices' colors and textures from hashmaps + if (blendColors) { colorA = sceneContext.vertexTerrainColor.getOrDefault(vertexKeyA, colorA); colorB = sceneContext.vertexTerrainColor.getOrDefault(vertexKeyB, colorB); colorC = sceneContext.vertexTerrainColor.getOrDefault(vertexKeyC, colorC); + } - if (plugin.configGroundTextures) { + if (plugin.configGroundTextures) { + if (blendTextures) { materialA = sceneContext.vertexTerrainTexture.getOrDefault(vertexKeyA, materialA); materialB = sceneContext.vertexTerrainTexture.getOrDefault(vertexKeyB, materialB); materialC = sceneContext.vertexTerrainTexture.getOrDefault(vertexKeyC, materialC); + } else if (groundMaterial != null) { + materialA = groundMaterial.getRandomMaterial( + worldPos[0] + (localVertices[0][0] >> LOCAL_COORD_BITS), + worldPos[1] + (localVertices[0][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); + materialB = groundMaterial.getRandomMaterial( + worldPos[0] + (localVertices[1][0] >> LOCAL_COORD_BITS), + worldPos[1] + (localVertices[1][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); + materialC = groundMaterial.getRandomMaterial( + worldPos[0] + (localVertices[2][0] >> LOCAL_COORD_BITS), + worldPos[1] + (localVertices[2][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); } - } else if (plugin.configGroundTextures && groundMaterial != null) { - materialA = groundMaterial.getRandomMaterial( - worldPos[0] + (localVertices[0][0] >> LOCAL_COORD_BITS), - worldPos[1] + (localVertices[0][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); - materialB = groundMaterial.getRandomMaterial( - worldPos[0] + (localVertices[1][0] >> LOCAL_COORD_BITS), - worldPos[1] + (localVertices[1][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); - materialC = groundMaterial.getRandomMaterial( - worldPos[0] + (localVertices[2][0] >> LOCAL_COORD_BITS), - worldPos[1] + (localVertices[2][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); } } else { // set colors for the shoreline to create a foam effect in the water shader diff --git a/src/main/java/rs117/hd/renderer/zone/SceneUploader.java b/src/main/java/rs117/hd/renderer/zone/SceneUploader.java index 0e801fb2ca..ef7e66fa10 100644 --- a/src/main/java/rs117/hd/renderer/zone/SceneUploader.java +++ b/src/main/java/rs117/hd/renderer/zone/SceneUploader.java @@ -883,16 +883,19 @@ private void uploadTilePaint( swMaterial = seMaterial = neMaterial = nwMaterial = material; } - boolean useBlendedMaterialAndColor = + boolean allowBlending = plugin.configGroundBlending && textureId == -1 && !proceduralGenerator.useDefaultColor(tile, override); + boolean blendColors = plugin.configGroundBlendingColors && allowBlending; + boolean blendTextures = plugin.configGroundBlendingTextures && allowBlending; + GroundMaterial groundMaterial = null; if (override != TileOverride.NONE) { groundMaterial = override.groundMaterial; uvOrientation = override.uvOrientation; uvScale = override.uvScale; - if (!useBlendedMaterialAndColor) { + if (!blendColors) { swColor = override.modifyColor(swColor); seColor = override.modifyColor(seColor); nwColor = override.modifyColor(nwColor); @@ -907,24 +910,25 @@ private void uploadTilePaint( groundMaterial = override.groundMaterial; } - if (useBlendedMaterialAndColor) { - // get the vertices' colors and textures from hashmaps + if (blendColors) { swColor = ctx.vertexTerrainColor.getOrDefault(swVertexKey, swColor); seColor = ctx.vertexTerrainColor.getOrDefault(seVertexKey, seColor); neColor = ctx.vertexTerrainColor.getOrDefault(neVertexKey, neColor); nwColor = ctx.vertexTerrainColor.getOrDefault(nwVertexKey, nwColor); + } - if (plugin.configGroundTextures) { + if (plugin.configGroundTextures) { + if (blendTextures) { swMaterial = ctx.vertexTerrainTexture.getOrDefault(swVertexKey, swMaterial); seMaterial = ctx.vertexTerrainTexture.getOrDefault(seVertexKey, seMaterial); neMaterial = ctx.vertexTerrainTexture.getOrDefault(neVertexKey, neMaterial); nwMaterial = ctx.vertexTerrainTexture.getOrDefault(nwVertexKey, nwMaterial); + } else if (groundMaterial != null) { + swMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1], worldPos[2]); + seMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1], worldPos[2]); + nwMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1] + 1, worldPos[2]); + neMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1] + 1, worldPos[2]); } - } else if (plugin.configGroundTextures && groundMaterial != null) { - swMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1], worldPos[2]); - seMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1], worldPos[2]); - nwMaterial = groundMaterial.getRandomMaterial(worldPos[0], worldPos[1] + 1, worldPos[2]); - neMaterial = groundMaterial.getRandomMaterial(worldPos[0] + 1, worldPos[1] + 1, worldPos[2]); } if (ctx.vertexIsOverlay.containsKey(neVertexKey) && ctx.vertexIsUnderlay.containsKey(neVertexKey)) @@ -1174,15 +1178,18 @@ private void uploadTileModel( GroundMaterial groundMaterial = null; - boolean useBlendedMaterialAndColor = + boolean allowBlending = plugin.configGroundBlending && textureId == -1 && !(isOverlay && proceduralGenerator.useDefaultColor(tile, override)); + boolean blendColors = plugin.configGroundBlendingColors && allowBlending; + boolean blendTextures = plugin.configGroundBlendingTextures && allowBlending; + if (override != TileOverride.NONE) { groundMaterial = override.groundMaterial; uvOrientation = override.uvOrientation; uvScale = override.uvScale; - if (!useBlendedMaterialAndColor) { + if (!blendColors) { colorA = override.modifyColor(colorA); colorB = override.modifyColor(colorB); colorC = override.modifyColor(colorC); @@ -1192,33 +1199,34 @@ private void uploadTileModel( groundMaterial = override.groundMaterial; } - if (useBlendedMaterialAndColor) { - // get the vertices' colors and textures from hashmaps + if (blendColors) { colorA = ctx.vertexTerrainColor.getOrDefault(vertexKeyA, colorA); colorB = ctx.vertexTerrainColor.getOrDefault(vertexKeyB, colorB); colorC = ctx.vertexTerrainColor.getOrDefault(vertexKeyC, colorC); + } - if (plugin.configGroundTextures) { + if (plugin.configGroundTextures) { + if (blendTextures) { materialA = ctx.vertexTerrainTexture.getOrDefault(vertexKeyA, materialA); materialB = ctx.vertexTerrainTexture.getOrDefault(vertexKeyB, materialB); materialC = ctx.vertexTerrainTexture.getOrDefault(vertexKeyC, materialC); + } else if (groundMaterial != null) { + materialA = groundMaterial.getRandomMaterial( + worldPos[0] + (vertices[0][0] >> LOCAL_COORD_BITS), + worldPos[1] + (vertices[0][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); + materialB = groundMaterial.getRandomMaterial( + worldPos[0] + (vertices[1][0] >> LOCAL_COORD_BITS), + worldPos[1] + (vertices[1][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); + materialC = groundMaterial.getRandomMaterial( + worldPos[0] + (vertices[2][0] >> LOCAL_COORD_BITS), + worldPos[1] + (vertices[2][1] >> LOCAL_COORD_BITS), + worldPos[2] + ); } - } else if (plugin.configGroundTextures && groundMaterial != null) { - materialA = groundMaterial.getRandomMaterial( - worldPos[0] + (vertices[0][0] >> LOCAL_COORD_BITS), - worldPos[1] + (vertices[0][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); - materialB = groundMaterial.getRandomMaterial( - worldPos[0] + (vertices[1][0] >> LOCAL_COORD_BITS), - worldPos[1] + (vertices[1][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); - materialC = groundMaterial.getRandomMaterial( - worldPos[0] + (vertices[2][0] >> LOCAL_COORD_BITS), - worldPos[1] + (vertices[2][1] >> LOCAL_COORD_BITS), - worldPos[2] - ); } } else if (onlyWaterSurface) { // set colors for the shoreline to create a foam effect in the water shader diff --git a/src/main/java/rs117/hd/utils/HDVariables.java b/src/main/java/rs117/hd/utils/HDVariables.java index 6e2132b7ad..0d1acadef6 100644 --- a/src/main/java/rs117/hd/utils/HDVariables.java +++ b/src/main/java/rs117/hd/utils/HDVariables.java @@ -14,6 +14,8 @@ public class HDVariables implements VariableSupplier { public static final String VAR_MODEL_TEXTURES = "modelTextures"; public static final String VAR_GROUND_TEXTURES = "groundTextures"; public static final String VAR_GROUND_BLENDING = "blending"; + public static final String VAR_GROUND_BLENDING_COLORS = "blendingColors"; + public static final String VAR_GROUND_BLENDING_TEXTURES = "blendingTextures"; public static final String VAR_HD_INFERNAL_TEXTURE = "hdInfernalCape"; public static final String VAR_LEGACY_INFERNAL_TEXTURE = "legacyInfernalCape"; @@ -37,7 +39,10 @@ public Object get(String name) { case VAR_GROUND_TEXTURES: return plugin.configGroundTextures; case VAR_GROUND_BLENDING: - return plugin.configGroundBlending; + case VAR_GROUND_BLENDING_COLORS: + return plugin.configGroundBlendingColors; + case VAR_GROUND_BLENDING_TEXTURES: + return plugin.configGroundBlendingTextures; case VAR_HD_INFERNAL_TEXTURE: return config.infernalCape() == InfernalCape.HD; case VAR_LEGACY_INFERNAL_TEXTURE: