Skip to content

Commit

Permalink
Try un-probit-ing IGN, too.
Browse files Browse the repository at this point in the history
This treats population bias differently from GOURD, though.
  • Loading branch information
tommyettinger committed Nov 22, 2024
1 parent 0c9001b commit 1c2cd82
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/github/tommyettinger/anim8/PaletteReducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3587,7 +3587,7 @@ public Pixmap reduceJimenez(Pixmap pixmap) {
Pixmap.Blending blending = pixmap.getBlending();
pixmap.setBlending(Pixmap.Blending.None);
int color;
final float strength = Math.min(0.6f * 32f * ditherStrength / (float) Math.pow(populationBias, 8f), 255f);
final float strength = Math.min(0.5f * ditherStrength * (float) Math.pow(populationBias, -4f), 1f);
for (int y = 0; y < h; y++) {
for (int px = 0; px < lineLen; px++) {
color = pixmap.getPixel(px, y);
Expand All @@ -3609,10 +3609,15 @@ public Pixmap reduceJimenez(Pixmap pixmap) {
// this is the 8-bit approximation to IGN:
// https://observablehq.com/d/92bc9c793858b2d7
// float adj = ((142 * px + 79 * y & 255) - 127.5f) * strength;
int xy = 142 * px + 79 * y;
// int rr = fromLinearLUT[(int)(toLinearLUT[(color >>> 24) ] + Math.min(Math.max(OtherMath.probitF(((xy + 0x36) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;
// int gg = fromLinearLUT[(int)(toLinearLUT[(color >>> 16) & 0xFF] + Math.min(Math.max(OtherMath.probitF(((xy + 0x53) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;
// int bb = fromLinearLUT[(int)(toLinearLUT[(color >>> 8) & 0xFF] + Math.min(Math.max(OtherMath.probitF(((xy + 0xC9) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;

int rr = fromLinearLUT[(int)(toLinearLUT[(color >>> 24) ] + (((xy + 0x36) & 255) - 127.5f) * strength)] & 255;
int gg = fromLinearLUT[(int)(toLinearLUT[(color >>> 16) & 0xFF] + (((xy + 0x53) & 255) - 127.5f) * strength)] & 255;
int bb = fromLinearLUT[(int)(toLinearLUT[(color >>> 8) & 0xFF] + (((xy + 0xC9) & 255) - 127.5f) * strength)] & 255;

int rr = fromLinearLUT[(int)(toLinearLUT[(color >>> 24) ] + Math.min(Math.max(OtherMath.probitF(((142 * px + 79 * y + 0x36) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;
int gg = fromLinearLUT[(int)(toLinearLUT[(color >>> 16) & 0xFF] + Math.min(Math.max(OtherMath.probitF(((142 * px + 79 * y + 0x53) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;
int bb = fromLinearLUT[(int)(toLinearLUT[(color >>> 8) & 0xFF] + Math.min(Math.max(OtherMath.probitF(((142 * px + 79 * y + 0xC9) & 255) * (1f / 255f)) * strength, -100f), 100f))] & 255;
pixmap.drawPixel(px, y, paletteArray[paletteMapping[((rr << 7) & 0x7C00)
| ((gg << 2) & 0x3E0)
| ((bb >>> 3))] & 0xFF]);
Expand Down

0 comments on commit 1c2cd82

Please sign in to comment.