Skip to content

Commit

Permalink
Neue's diff matches Scatter; gamma, strength.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Dec 6, 2024
1 parent 3286ea8 commit 9c19feb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/github/tommyettinger/anim8/PaletteReducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4510,9 +4510,9 @@ public Pixmap reduceNeue(Pixmap pixmap) {
float rdiff, gdiff, bdiff;
float er, eg, eb;
byte paletteIndex;
float w1 = ditherStrength * 7f, w3 = w1 * 3f, w5 = w1 * 5f, w7 = w1 * 7f,
adj, strength = (32f * ditherStrength / (populationBias * populationBias * populationBias)),
limit = (float) Math.pow(80, 1.635 - populationBias);
float w1 = ditherStrength * 8f, w3 = w1 * 3f, w5 = w1 * 5f, w7 = w1 * 7f,
adj, strength = (70f * ditherStrength / (populationBias * populationBias * populationBias)),
limit = Math.min(127, (float) Math.pow(80, 1.635 - populationBias));

for (int py = 0; py < h; py++) {
int ny = py + 1;
Expand All @@ -4536,18 +4536,18 @@ public Pixmap reduceNeue(Pixmap pixmap) {
eg = adj + (curErrorGreen[px]);
eb = adj + (curErrorBlue[px]);

int rr = Math.min(Math.max((int)(((color >>> 24) ) + er + 0.5f), 0), 0xFF);
int gg = Math.min(Math.max((int)(((color >>> 16) & 0xFF) + eg + 0.5f), 0), 0xFF);
int bb = Math.min(Math.max((int)(((color >>> 8) & 0xFF) + eb + 0.5f), 0), 0xFF);
int rr = fromLinearLUT[(int)Math.min(Math.max(toLinearLUT[(color >>> 24) ] + er, 0), 1023)] & 255;
int gg = fromLinearLUT[(int)Math.min(Math.max(toLinearLUT[(color >>> 16) & 0xFF] + eg, 0), 1023)] & 255;
int bb = fromLinearLUT[(int)Math.min(Math.max(toLinearLUT[(color >>> 8) & 0xFF] + eb, 0), 1023)] & 255;
paletteIndex =
paletteMapping[((rr << 7) & 0x7C00)
| ((gg << 2) & 0x3E0)
| ((bb >>> 3))];
used = paletteArray[paletteIndex & 0xFF];
pixmap.drawPixel(px, py, used);
rdiff = (0x1.7p-10f * ((color>>>24)- (used>>>24)) );
gdiff = (0x1.7p-10f * ((color>>>16&255)-(used>>>16&255)));
bdiff = (0x1.7p-10f * ((color>>>8&255)- (used>>>8&255)) );
rdiff = (0x2.Ep-8f * ((color>>>24)- (used>>>24)) );
gdiff = (0x2.Ep-8f * ((color>>>16&255)-(used>>>16&255)));
bdiff = (0x2.Ep-8f * ((color>>>8&255)- (used>>>8&255)) );
rdiff *= 1.25f / (0.25f + Math.abs(rdiff));
gdiff *= 1.25f / (0.25f + Math.abs(gdiff));
bdiff *= 1.25f / (0.25f + Math.abs(bdiff));
Expand Down

0 comments on commit 9c19feb

Please sign in to comment.