New community dev tool uploaded: 12-bit palette script for Aseprite

All aspects of programming on the Commander X16.
Post Reply
izb
Posts: 31
Joined: Thu May 21, 2020 10:04 am

New community dev tool uploaded: 12-bit palette script for Aseprite

Post by izb »




12-bit palette script for Aseprite




View File






Aseprite script that converts the current palette into a 12-bit (4096 colour) palette, i.e. 4-bits per channel.

To install in Aseprite, go to File -> Scripts -> Open scripts folder

Then drop the script into that folder and restart Aseprite. You might also want to assign a hotkey to the script via Edit -> Keyboard Shortcuts. 

It's also useful for things like creating gradients. Just create a gradient in the normal way, then run the script, and each colour in the palette will be nudged into the closest CX16 colour.






 
User avatar
AndyMt
Posts: 326
Joined: Sun Jun 21, 2020 3:02 pm
Location: Switzerland

New community dev tool uploaded: 12-bit palette script for Aseprite

Post by AndyMt »


I've used this script for a while now, thanks a lot for this. I'm think I stumbled across something in regards to the conversion.

As it's a bit complicated I'll try to explain it:

Colors appear different in emulator:

Recently I noticed that the colors in the emulator appear slightly different than in Aseprite (using your script). Looking at the script it appears it rounds everything to a palette entry ending with "0" for each rgb value:

0x00, 0x10, 0x20, 0x30... 0xE0, 0xFF << you can see here that there is a gap of 31 values at then end and 16 in between all others...

The emulator produces each entry mostly with the same hex digits for each tuple (using screenshots and Gimp to determine color values). So:

0x00, 0x11, 0x22, 0x33... 0xEE, 0xFF << here the gap is 17 between each color value.

why this can be an issue:

The script currently adds 8 and then discards the lower nibble. I think the thresholds for each of the 16 values per color value needs to be different. Right now there is a big gap in the brighter colors, which leads to color bleeding towards the slightly dimmer ones.

Script algorithm changes:

What I have done now is to change the script slightly and emit the above RGB values, so Gimp, Pro Motion, Aseprite etc. show the right colors (as the emulator would) and also use those for dithering. Of course VERA then can only use the upper 4 bits of each palette entry. Tools like Aloevera etc. take care of that. Using this delivered better results for me when working with large (320x240 - haha) bitmaps like I used in Brixx and Invaderz.

It probably doesn't matter that much for sprites and tiles etc.

I attach my (not very elegant) version of the script so you can see the difference.

12-bit Palette Quantize V2.lua

izb
Posts: 31
Joined: Thu May 21, 2020 10:04 am

New community dev tool uploaded: 12-bit palette script for Aseprite

Post by izb »

I've used this script for a while now, thanks a lot for this. I'm think I stumbled across something in regards to the conversion.
As it's a bit complicated I'll try to explain it:
Colors appear different in emulator:
Recently I noticed that the colors in the emulator appear slightly different than in Aseprite (using your script). Looking at the script it appears it rounds everything to a palette entry ending with "0" for each rgb value:
0x00, 0x10, 0x20, 0x30... 0xE0, 0xFF The emulator produces each entry mostly with the same hex digits for each tuple (using screenshots and Gimp to determine color values). So:
0x00, 0x11, 0x22, 0x33... 0xEE, 0xFF why this can be an issue:
The script currently adds 8 and then discards the lower nibble. I think the thresholds for each of the 16 values per color value needs to be different. Right now there is a big gap in the brighter colors, which leads to color bleeding towards the slightly dimmer ones.
Script algorithm changes:
What I have done now is to change the script slightly and emit the above RGB values, so Gimp, Pro Motion, Aseprite etc. show the right colors (as the emulator would) and also use those for dithering. Of course VERA then can only use the upper 4 bits of each palette entry. Tools like Aloevera etc. take care of that. Using this delivered better results for me when working with large (320x240 - haha) bitmaps like I used in Brixx and Invaderz.
It probably doesn't matter that much for sprites and tiles etc.
I attach my (not very elegant) version of the script so you can see the difference.
12-bit Palette Quantize V2.lua

Yeah I updated the script to use the correct colours some time ago. Not sure why the version you had still discarded the lower nybble.


Sent from my iPhone using Tapatalk
User avatar
AndyMt
Posts: 326
Joined: Sun Jun 21, 2020 3:02 pm
Location: Switzerland

New community dev tool uploaded: 12-bit palette script for Aseprite

Post by AndyMt »


Oh boy - should have checked for updates before I posted ?.

izb
Posts: 31
Joined: Thu May 21, 2020 10:04 am

New community dev tool uploaded: 12-bit palette script for Aseprite

Post by izb »

Oh boy - should have checked for updates before I posted [emoji1].

[emoji3]


Sent from my iPhone using Tapatalk
Post Reply