Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/rs117/hd/HdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/rs117/hd/HdPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.<br>" +
"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;
}

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/rs117/hd/config/GroundBlending.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
70 changes: 39 additions & 31 deletions src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
70 changes: 39 additions & 31 deletions src/main/java/rs117/hd/renderer/zone/SceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/rs117/hd/utils/HDVariables.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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:
Expand Down