Search This Blog

what is this i don't even

[Originally written July 17 2020]

While I’ve worked out how to determine from a creature’s genetics what its actual color values will be, and I have a good understanding of how RGB itself works, I’m still missing a piece of the puzzle: how to predict exactly what the visuals will look like from those numbers. As demonstrated in this image, color rotation in Creatures 3 clearly does not correspond perfectly to that in Photoshop; the second Norn from the left has a rotation value of 191, which is exactly 1/6th of the way around the color wheel. The same amount of rotation in photoshop produces the third Norn, who is much brighter than the one in-game, although her hues are correct; the fourth image is the third one with the saturation cranked way down. So how exactly do the colors get calculated?

I decided to do some experimentation to find out. Rather than hatching edited creatures though, I simply played around with the TARG HOTS TINT command and a beach ball. Specifically, I recolored it multiple times and took screenshots, then used photoshop to find the RGB values of four specific pixels – one in each major colored section of the ball. 

This massive pile of data turned out to be less helpful than I’d hoped. For one thing, it showed that the rotation was not complete – in theory, at a value of 255, the blue channel value should equal the original value of the red channel, and so on. My data showed that it usually ended up being slightly less than the expected value – except sometimes it wasn’t. And while it usually did end up being less, I couldn’t find any pattern to how much less – not by straight value, not by percentage of starting value, not by percentage of theoretical target value. For another thing, the graphs were… weird. Wobbly. I couldn’t make heads or tails of them no matter how I tried.

I decided to examine the blue channel from the point in the red section of the ball in more detail. Unable to comprehend a pattern to it, I decided to gather more data for a finer-grained look at the 176-184 section of the graph. I repeated my recoloring and plotting procedure for every possible value in that section. It only confused me more.

There is a definite stair-stepping pattern here. A channel will remain at a particular number for several rotation values, then suddenly jump to a new value, and remain there. But the channels do not all jump at the same time. I clearly needed to increase the resolution of the whole graph, and who knew how many times I would need to do so before I could get a truly accurate picture of what was going on… so I bit the bullet and started graphing every single value until a pattern emerged.

Red PointYellow PointGreen PointBlue Point
RotationRGBRotationRGBRotationRGBRotationRGB
128198482412825525141128166516128332482
12918944241292552474112916608129242474
13018944241302552434113016608130242474
13118944241312552434113116608131242474
13218944241322552394113216608132242474
13318144241332552394113316608133242474
13418144241342552394913416608134242474
13518144331352552354913516608135242474
13618144331362552354913616608136242874
13718144331372552314913716608137242874
13818144331382552314913816568138242874
13918144331392552315713916568139242874
14017344331402552275714016568140242874
14117344331412552275714116568141242874
14217344411422552235714216568142242874
14317344411432552235714316568143242874
14417344411442552236614416568144242874
14517344411452552196614516568145243274
14617344411462552196614616568146243266

One thing that popped out immediately is that this is a stair step function – it stays at a value, then simply jumps to another one without a smooth transition, then stays at that value, and so on; I marked the points where the value changed with a bold number in the table. I was starting to see something of a pattern emerge, so I color coded the numbers by how much the value changed. I soon picked up that the red and blue channels changed according to a pattern: three changes by 8, then a change by 9. After additional graphing of the yellow point (which had the most green channel changes) I was able to nail down that pattern as well: fifteen changes by 4, then a change by 5.

This sort of pattern in computing is generally indicative of computing integers (which slice off any decimal points rather than rounding) with math involving non-whole numbers. In this case, the pattern of change for the green channel is consistent with that generated by Floor(4.0625*n) and the blue and red channels consistent with Floor(8.25*n). But how to predict when the jumps happen? And why does the blue channel in the green point, which should not change, go from 16 to 8 and then back to 16? Pseudocode for how the colors work was available on the official website but it’s obviously incomplete and probably completely wrong. Perhaps I’ll come back to this another time.

No comments:

Post a Comment