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
2 changes: 2 additions & 0 deletions src/main/java/rs117/hd/HdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ public class HdPlugin extends Plugin {
public boolean configPowerSaving;
public boolean configUnlitFaceColors;
public boolean configUndoVanillaShading;
public boolean configTileBiasing;
public boolean configPreserveVanillaNormals;
public boolean configWindDisplacement;
public boolean configCharacterDisplacement;
Expand Down Expand Up @@ -1631,6 +1632,7 @@ private void updateCachedConfigs() {
configShadingMode = config.shadingMode();
configUnlitFaceColors = configShadingMode.unlitFaceColors;
configUndoVanillaShading = configShadingMode.undoVanillaShading;
configTileBiasing = config.tileBiasing();
configPreserveVanillaNormals = config.preserveVanillaNormals();
configWindDisplacement = config.windDisplacement();
configCharacterDisplacement = config.characterDisplacement();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/rs117/hd/HdPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,15 @@ default boolean vanillaColorBanding() {
return false;
}

String KEY_TILE_BIASING = "tileBiasing";
@ConfigItem(
keyName = KEY_TILE_BIASING,
name = "Fix ground clipping",
description = "Biases dropped items & actors to reduce the amount of ground clipping.",
section = miscellaneousSettings
)
default boolean tileBiasing() { return true; }

String KEY_LOW_MEMORY_MODE = "lowMemoryMode";
@ConfigItem(
keyName = KEY_LOW_MEMORY_MODE,
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/rs117/hd/renderer/zone/ModelStreamingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ public void drawTemp(Projection worldProjection, Scene scene, GameObject gameObj
}
plugin.drawnTempRenderableCount++;

final int tileExX = (x >> Perspective.LOCAL_COORD_BITS) + ctx.sceneContext.sceneOffset;
final int tileExY = (z >> Perspective.LOCAL_COORD_BITS) + ctx.sceneContext.sceneOffset;

final int modelBias;
if(plugin.configTileBiasing && renderable instanceof Actor) {
Tile tile = scene.getExtendedTiles()[gameObject.getPlane()][tileExX][tileExY];
modelBias = tile != null && tile.getGroundObject() != null ? 125 : 0;
} else {
modelBias = 0;
}

final boolean isModelPartiallyVisible = sceneManager.isRoot(ctx) && modelClassification == 0;
final boolean hasAlpha = renderable instanceof Player || m.getFaceTransparencies() != null;
final AsyncCachedModel asyncModelCache = obtainAvailableAsyncCachedModel(false);
Expand All @@ -216,6 +227,7 @@ public void drawTemp(Projection worldProjection, Scene scene, GameObject gameObj
modelOverride,
zone,
cachedModel,
modelBias,
isModelPartiallyVisible,
hasAlpha,
orientation, x, y, z
Expand All @@ -242,6 +254,7 @@ public void drawTemp(Projection worldProjection, Scene scene, GameObject gameObj
modelOverride,
zone,
m,
modelBias,
isModelPartiallyVisible,
hasAlpha,
orientation, x, y, z
Expand All @@ -263,6 +276,7 @@ private void uploadTempModel(
ModelOverride modelOverride,
Zone zone,
Model m,
int modelBias,
boolean isModelPartiallyVisible,
boolean hasAlpha,
int orientation, int x, int y, int z
Expand Down Expand Up @@ -323,6 +337,7 @@ private void uploadTempModel(
modelOverride,
preOrientation,
orientation,
modelBias,
isSquashed,
opaqueView,
alphaView
Expand Down Expand Up @@ -449,6 +464,17 @@ public void drawDynamic(
if (renderThreadId >= 0)
client.checkClickbox(projection, m, orient, x, y, z, tileObject.getHash());

final int tileExX = (x >> Perspective.LOCAL_COORD_BITS) + ctx.sceneContext.sceneOffset;
final int tileExY = (z >> Perspective.LOCAL_COORD_BITS) + ctx.sceneContext.sceneOffset;

final int modelBias;
if(plugin.configTileBiasing && r instanceof TileItem) {
Tile tile = scene.getExtendedTiles()[tileObject.getPlane()][tileExX][tileExY];
modelBias = tile != null && tile.getGroundObject() != null ? 125 : 0;
} else {
modelBias = 0;
}

final boolean isModelPartiallyVisible = sceneManager.isRoot(ctx) && modelClassification == 0;
final AsyncCachedModel asyncModelCache = obtainAvailableAsyncCachedModel(renderThreadId >= 0);
if (asyncModelCache != null) {
Expand All @@ -467,9 +493,11 @@ public void drawDynamic(
tileObject,
modelOverride,
cachedModel,
r,
zone,
isModelPartiallyVisible,
hasAlpha,
modelBias,
preOrientation, orient,
x, y, z
);
Expand All @@ -496,9 +524,11 @@ public void drawDynamic(
tileObject,
modelOverride,
m,
r,
zone,
isModelPartiallyVisible,
hasAlpha,
modelBias,
preOrientation, orient,
x, y, z
);
Expand All @@ -515,9 +545,11 @@ private void uploadDynamicModel(
TileObject tileObject,
ModelOverride modelOverride,
Model m,
Renderable r,
Zone zone,
boolean isModelPartiallyVisible,
boolean hasAlpha,
int modelBias,
int preOrientation,
int orient,
int x,
Expand Down Expand Up @@ -577,6 +609,7 @@ private void uploadDynamicModel(
modelOverride,
preOrientation,
orient,
modelBias,
isSquashed,
opaqueView,
alphaView
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/rs117/hd/renderer/zone/SceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1917,13 +1917,27 @@ public boolean preprocessTempModel(
return shouldSort;
}

public void uploadTempModel(
PrimitiveIntArray faces,
Model model,
ModelOverride modelOverride,
int preOrientation,
int orientation,
boolean isShadow,
DynamicModelVAO.View opaqueView,
DynamicModelVAO.View alphaView
) {
uploadTempModel(faces, model, modelOverride, preOrientation, orientation, 0, isShadow, opaqueView, alphaView);
}

// temp draw
public void uploadTempModel(
PrimitiveIntArray faces,
Model model,
ModelOverride modelOverride,
int preOrientation,
int orientation,
int modelBias,
boolean isShadow,
DynamicModelVAO.View opaqueView,
DynamicModelVAO.View alphaView
Expand Down Expand Up @@ -1956,7 +1970,7 @@ public void uploadTempModel(
final byte[] bias = model.getFaceBias();
final int[] faceNormals = isShadow ? EMPTY_NORMALS : modelNormals;

final boolean hasBias = bias != null;
final boolean hasVanillaBias = bias != null;
final boolean modelHasNormals =
model.getVertexNormalsX() != null &&
model.getVertexNormalsY() != null &&
Expand Down Expand Up @@ -2065,8 +2079,9 @@ else if (color3 == -1)
color3 = interpolateHSL(color3, overrideHue, overrideSat, overrideLum, overrideAmount);
}

final int depthBias = faceOverride.depthBias != -1 ? faceOverride.depthBias :
hasBias ? bias[face] & 0xFF : 0;
int depthBias = faceOverride.depthBias != -1 ? faceOverride.depthBias :
hasVanillaBias ? bias[face] & 0xFF : 0;
depthBias = clamp(modelBias + depthBias, 0, 0xFF);
final int packedAlphaBiasHsl = transparency << 24 | depthBias << 16;
final boolean hasAlpha = material.hasTransparency || transparency != 0;

Expand Down