[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 Point | Yellow Point | Green Point | Blue Point | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Rotation | R | G | B | Rotation | R | G | B | Rotation | R | G | B | Rotation | R | G | B |
128 | 198 | 48 | 24 | 128 | 255 | 251 | 41 | 128 | 16 | 65 | 16 | 128 | 33 | 24 | 82 |
129 | 189 | 44 | 24 | 129 | 255 | 247 | 41 | 129 | 16 | 60 | 8 | 129 | 24 | 24 | 74 |
130 | 189 | 44 | 24 | 130 | 255 | 243 | 41 | 130 | 16 | 60 | 8 | 130 | 24 | 24 | 74 |
131 | 189 | 44 | 24 | 131 | 255 | 243 | 41 | 131 | 16 | 60 | 8 | 131 | 24 | 24 | 74 |
132 | 189 | 44 | 24 | 132 | 255 | 239 | 41 | 132 | 16 | 60 | 8 | 132 | 24 | 24 | 74 |
133 | 181 | 44 | 24 | 133 | 255 | 239 | 41 | 133 | 16 | 60 | 8 | 133 | 24 | 24 | 74 |
134 | 181 | 44 | 24 | 134 | 255 | 239 | 49 | 134 | 16 | 60 | 8 | 134 | 24 | 24 | 74 |
135 | 181 | 44 | 33 | 135 | 255 | 235 | 49 | 135 | 16 | 60 | 8 | 135 | 24 | 24 | 74 |
136 | 181 | 44 | 33 | 136 | 255 | 235 | 49 | 136 | 16 | 60 | 8 | 136 | 24 | 28 | 74 |
137 | 181 | 44 | 33 | 137 | 255 | 231 | 49 | 137 | 16 | 60 | 8 | 137 | 24 | 28 | 74 |
138 | 181 | 44 | 33 | 138 | 255 | 231 | 49 | 138 | 16 | 56 | 8 | 138 | 24 | 28 | 74 |
139 | 181 | 44 | 33 | 139 | 255 | 231 | 57 | 139 | 16 | 56 | 8 | 139 | 24 | 28 | 74 |
140 | 173 | 44 | 33 | 140 | 255 | 227 | 57 | 140 | 16 | 56 | 8 | 140 | 24 | 28 | 74 |
141 | 173 | 44 | 33 | 141 | 255 | 227 | 57 | 141 | 16 | 56 | 8 | 141 | 24 | 28 | 74 |
142 | 173 | 44 | 41 | 142 | 255 | 223 | 57 | 142 | 16 | 56 | 8 | 142 | 24 | 28 | 74 |
143 | 173 | 44 | 41 | 143 | 255 | 223 | 57 | 143 | 16 | 56 | 8 | 143 | 24 | 28 | 74 |
144 | 173 | 44 | 41 | 144 | 255 | 223 | 66 | 144 | 16 | 56 | 8 | 144 | 24 | 28 | 74 |
145 | 173 | 44 | 41 | 145 | 255 | 219 | 66 | 145 | 16 | 56 | 8 | 145 | 24 | 32 | 74 |
146 | 173 | 44 | 41 | 146 | 255 | 219 | 66 | 146 | 16 | 56 | 8 | 146 | 24 | 32 | 66 |
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