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
20 changes: 19 additions & 1 deletion src/main/java/rs117/hd/renderer/zone/SceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,12 @@ private int uploadStaticModel(
}
}

if (faceOverride.shiftsColor()) {
color1 = faceOverride.modifyColor(color1);
color2 = faceOverride.modifyColor(color2);
color3 = faceOverride.modifyColor(color3);
}

int textureFace = textureFaces != null ? textureFaces[face] : -1;
if (material != Material.NONE) {
uvType = faceOverride.uvType;
Expand Down Expand Up @@ -1657,6 +1663,9 @@ private int uploadStaticModel(
if (shouldRotateNormals)
rotateNormals(modelNormals, orientSin, orientCos);

if (faceOverride.shiftsAlpha())
transparency = faceOverride.modifyAlpha(transparency);

int depthBias = faceOverride.depthBias != -1 ? faceOverride.depthBias :
bias == null ? 0 : bias[face] & 0xFF;
int packedAlphaBiasHsl = transparency << 24 | depthBias << 16;
Expand Down Expand Up @@ -1993,7 +2002,7 @@ public void uploadTempModel(
else if (color3 == -1)
color2 = color3 = color1;

final int transparency = transparencies != null ? transparencies[face] & 0xFF : 0;
int transparency = transparencies != null ? transparencies[face] & 0xFF : 0;
final int textureFace = textureFaces != null ? textureFaces[face] : -1;
final int textureId = isVanillaTextured ? faceTextures[face] : -1;
final UvType uvType = faceUVTypes[face];
Expand All @@ -2003,6 +2012,12 @@ else if (color3 == -1)
if (textureId != -1)
color1 = color2 = color3 = 90;

if (faceOverride.shiftsColor()) {
color1 = faceOverride.modifyColor(color1);
color2 = faceOverride.modifyColor(color2);
color3 = faceOverride.modifyColor(color3);
}

final int materialData = material.packMaterialData(faceOverride, uvType, false);

final int triangleA = indices1[face];
Expand Down Expand Up @@ -2068,6 +2083,9 @@ else if (color3 == -1)
color3 = interpolateHSL(color3, overrideHue, overrideSat, overrideLum, overrideAmount);
}

if (faceOverride.shiftsAlpha())
transparency = faceOverride.modifyAlpha(transparency);

final int depthBias = faceOverride.depthBias != -1 ? faceOverride.depthBias :
hasBias ? bias[face] & 0xFF : 0;
final int packedAlphaBiasHsl = transparency << 24 | depthBias << 16;
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/rs117/hd/scene/model_overrides/ModelOverride.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public class ModelOverride
public float shadowOpacityThreshold = 0;
public TzHaarRecolorType tzHaarRecolorType = TzHaarRecolorType.NONE;
public InheritTileColorType inheritTileColorType = InheritTileColorType.NONE;
private int shiftHue;
private int minHue;
private int maxHue = 63;
private int shiftSaturation;
private int minSaturation;
private int maxSaturation = 7;
private int shiftLightness;
private int minLightness;
private int maxLightness = 127;
private int shiftAlpha;
private int minAlpha;
private int maxAlpha = 255;
public WindDisplacement windDisplacementMode = WindDisplacement.DISABLED;
public int windDisplacementModifier = 0;
public boolean invertDisplacementStrength = false;
Expand Down Expand Up @@ -244,6 +256,18 @@ public ModelOverride copy() {
shadowOpacityThreshold,
tzHaarRecolorType,
inheritTileColorType,
shiftHue,
minHue,
maxHue,
shiftSaturation,
minSaturation,
maxSaturation,
shiftLightness,
minLightness,
maxLightness,
shiftAlpha,
minAlpha,
maxAlpha,
windDisplacementMode,
windDisplacementModifier,
invertDisplacementStrength,
Expand Down Expand Up @@ -625,6 +649,38 @@ public void revertRotation(Model model) {
}
}

public boolean shiftsColor() {
return shiftHue != 0 || shiftSaturation != 0 || shiftLightness != 0
|| minHue != 0 || maxHue != 63
|| minSaturation != 0 || maxSaturation != 7
|| minLightness != 0 || maxLightness != 127;
}

public boolean shiftsAlpha() {
return shiftAlpha != 0 || minAlpha != 0 || maxAlpha != 255;
}

public int modifyAlpha(int alpha) {
alpha += shiftAlpha;
return clamp(alpha, minAlpha, maxAlpha);
}

public int modifyColor(int jagexHsl) {
int h = jagexHsl >> 10 & 0x3F;
h += shiftHue;
h = clamp(h, minHue, maxHue);

int s = jagexHsl >> 7 & 7;
s += shiftSaturation;
s = clamp(s, minSaturation, maxSaturation);

int l = jagexHsl & 0x7F;
l += shiftLightness;
l = clamp(l, minLightness, maxLightness);

return h << 10 | s << 7 | l;
}

@Nullable
public final ModelOverride testColorOverrides(int ahsl) {
ModelOverride override = null;
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/rs117/hd/scene/model_overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -78819,6 +78819,10 @@
"baseMaterial": "GEM_STONE",
"uvScale": 1.1,
"uvOrientation": 512,
"shiftSaturation": -7,
"shiftLightness": 30,
"maxLightness": 100,
"shiftAlpha": 175,
"areas": [
"SHILO_VILLAGE_MINE",
"SHILO_VILLAGE_MINE_SURFACE"
Expand Down Expand Up @@ -78909,6 +78913,9 @@
"description": "Rock - Gems - Gem rocks - Small",
"baseMaterial": "GRUNGE_3_SHINY",
"uvType": "BOX",
"shiftSaturation": -7,
"shiftLightness": 30,
"maxLightness": 100,
"colorOverrides": [
{
"description": "Rock",
Expand All @@ -78928,6 +78935,9 @@
"description": "Rock - Gems - Gem rocks - Large",
"baseMaterial": "GRUNGE_3_SHINY",
"uvType": "BOX",
"shiftSaturation": -70,
"shiftLightness": 30,
"maxLightness": 100,
"colorOverrides": [
{
"description": "Rock",
Expand Down