planet texture map conversion

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

After a lot of interactive work with Claude AI, I have a decent functioning character set conversion tool. It takes any source image, and produces a 'map' and a 'character set' of arbitrary size. Essentially I want to convert planetary texture maps into Atari-2600 compatible images.

Specifically, I'm using ChronoColour, so I want the format to be compatible with that.  And of course I'm using the Atari 2600 colours so it needs to be compatible with that.  The CC system uses just 3 colours, to be exact, mixed temporally and spatially to achieve 8 virtual colours.  So it needs to account for that.

In this series of posts, I'm showing the original texture, and the converted character set/map (converted BACK to an image using just the character set and palette from the '2600 side).  Given the extreme limitations, the colours aren't going to be exactly the same. But, hopefully good enough to act as textures for the spinning planet.

Note, the generated images are 8 colours, but those are formed from just 3 primary colours in palette positions 1,2,4.  The other colours are mixtures of those, just as per the ChronoColour system function.

I can adjust the brightness via command-line param, have dithered or non-dithered, set the output size, and most importantly define the number of characters to use in the character set.


The tool source is attached. It's quite an impressive bit of work by the AI.  The process to produce it, though, was VERY long and interactive - taking many twists and turns.

The next thing to do, of course, is use these texture maps in the spinning planet display. The results should be REALLY interesting. Hopefully no 'gotchas' will show up.

Also note my original spinning globe code mapped a flat playfield onto a sphere -- in both x and y axes the wrapping was done.  But these textures already do the wrapping in the vertical, so that will simplify my code greatly.


Samples to follow... note that the tool extends the width of the map by 10 chars, allowing the code to not have to worry about wrapping left/right when drawing the texture.  So earth, for example, has two south americas.





Andrew Davie

Earth

Note the palettes in the .c file

static const unsigned char earth_palette[8][3] = {
    {   0,   0,   0 },  /* 0: origin */
    {  56,  84, 168 },  /* 1: +P1 */
    { 132, 140,  76 },  /* 2: +P2 */
    {  94, 112, 122 },  /* 3: +P1+P2 */
    { 236, 236, 236 },  /* 4: +P3 */
    { 146, 160, 202 },  /* 5: +P1+P3 */
    { 184, 188, 156 },  /* 6: +P2+P3 */
    { 141, 153, 160 },  /* 7: +P1+P2+P3 */
};

/* NTSC Atari 2600 companion palette: nearest TIA register values for
 * palette primaries (indices 1, 2, 4 — the single-bit entries). */
static const unsigned char earth_ntsc_palette[3] = {
    0x94,  /* palette[1] = (56,84,168) */
    0xE6,  /* palette[2] = (132,140,76) */
    0x0E,  /* palette[4] = (236,236,236) */
};


The NTSC colour values (0x94) are determined to represent RGB values (56,84,168) which are plonked into the earth_palette array at indexes 1,2,4.  The others (3,5,6,7) are generated by blending those original 3, thus giving the reconstructed image a reasonable representation of what it SHOULD look like in ChronoColour.

Andrew Davie

#2
Mars

  P1 (dark)  134, 71, 55
  P2 (mid)   204, 99, 64
  P3 (bright)243,236,232
NTSC snapping:
  P1 (134, 71, 55)  ->  TIA 0x24  ->  NTSC (152, 92, 40)
  P2 (204, 99, 64)  ->  TIA 0x36  ->  NTSC (192,104, 72)
  P3 (243,236,232)  ->  TIA 0x0E  ->  NTSC (236,236,236)
NTSC-anchored palette (TIA 0x24 / 0x36 / 0x0E):
  [0]   0,  0,  0  (origin)
  [1] 152, 92, 40  (+P1)
  [2] 192,104, 72  (+P2)
  [3] 172, 98, 56  (+P1+P2)
  [4] 236,236,236  (+P3)
  [5] 194,164,138  (+P1+P3)
  [6] 214,170,154  (+P2+P3)
  [7] 193,144,116  (+P1+P2+P3)
unique characters before reduction: 119 (incl. 8 locked solid colours)
  reducing charset: 39/39 merges done
input image       : textures/mars.png
palette           : adaptive (k-means)
map size (chars)   : 30 x 6 (input 20 wide + 10 wrap buffer)
trixel resolution  : 100 x 60
charset budget     : 80
unique before merge: 119
characters used    : 80 (39 pairs merged)
output file        : mars.c
NTSC palette (TIA) : [1]=0x24 (152,92,40)  [2]=0x36 (192,104,72)  [4]=0x0E (236,236,236)
reconstructed PNG  : mars_recon.png (native 150x60 px, scale x4)

Andrew Davie

Here's Mars with 128 chars instead of 80...

Better but maybe not worth the extra chars.  Good thing is, it's now simple to adjust.  A few seconds.



Andrew Davie

#4
The sun!

Here we see character set limitations (80 chars) causing artifacting because the sun is very high-frequency I guess you'd say.  The 2nd version has 128 chars, which is much improved.

k-means k=3 primaries (before NTSC snap):
  P1 (dark)  229, 91, 10
  P2 (mid)   253,166, 48
  P3 (bright)253,214,126
NTSC snapping:
  P1 (229, 91, 10)  ->  TIA 0x34  ->  NTSC (172, 80, 48)
  P2 (253,166, 48)  ->  TIA 0x2A  ->  NTSC (204,160, 92)
  P3 (253,214,126)  ->  TIA 0xFC  ->  NTSC (232,212,132)
NTSC-anchored palette (TIA 0x34 / 0x2A / 0xFC):
  [0]   0,  0,  0  (origin)
  [1] 172, 80, 48  (+P1)
  [2] 204,160, 92  (+P2)
  [3] 188,120, 70  (+P1+P2)
  [4] 232,212,132  (+P3)
  [5] 202,146, 90  (+P1+P3)
  [6] 218,186,112  (+P2+P3)
  [7] 203,151, 91  (+P1+P2+P3)
unique characters before reduction: 124 (incl. 8 locked solid colours)
  reducing charset: 44/44 merges done
input image       : textures/sun.png
palette           : adaptive (k-means)
map size (chars)   : 30 x 6 (input 20 wide + 10 wrap buffer)
trixel resolution  : 100 x 60
charset budget     : 80
unique before merge: 124
characters used    : 80 (44 pairs merged)
output file        : sun.c
NTSC palette (TIA) : [1]=0x34 (172,80,48)  [2]=0x2A (204,160,92)  [4]=0xFC (232,212,132)



Andrew Davie

Just to show the dynamic nature of the tool, here's earth with 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 chars in the charset. Just because.

There's also a saturated version where I saturated the colours of the source image.
Result is... OK.

Andrew Davie

#6
Io.  Io is high-frequency, so I've allowed 128 chars...
2nd version saturated + brighter


Andrew Davie

Moon.


Andrew Davie

Pluto.  Problematic.

Andrew Davie

#9
Neptune. Will be interesting to see running.
Dithered, darker version included, too.

Andrew Davie

Mercury.


Andrew Davie

It works!

Almost no changes to the code; just pointing to the data. 
It's not perfect; I need to adjust the mapping vertically so it looks a little odd.
But, basically, it's beautiful!


Andrew Davie

Still working on this. It's a bit tricky.


Andrew Davie

#13
Still working on this.  I decided to go with mostly generated planets, as they show off the texture mapping and rotation far better than the plain gas-giants such as Jupiter Neptune and Uranus.  There's still a glitch or two in the mapping; I've been reducing the source texture size as much as possible, to save ROM. It's getting there.



Note: This video is in iCC, whereas the game will default to pCC.

Andrew Davie

#14
Here's a binary with a few planets.
No user interactivity - just watch the light show.