Jump to content

Ark Color Codes - An in depth look at the colors, parsing exports, and more!


DJRedNightMC

Recommended Posts

Hello Fellow Survivalists!

This is going to be my first of hopefully many different posts here on the forums.

After searching and searching, there was no clear answer to how the Ark Colors are actually calculated. Sure, the wiki has the hexadecimal color codes, but what if you want to create your own API or web app that accepts the exported dino .ini file. Not much use for hexadecimal color codes if you're given a random string that doesn't conform to the RGBA Integer syntax and can't be parsed easily. So where do we go from here?

TL;DR

If you want to skip the boring stuff, here's a link to my spreadsheet that has all RGB and Hex values that are parsed from all 100 dino color exports.

https://docs.google.com/spreadsheets/d/1sW4U5aWDZ0hjgkLxAa_n1a3HLWFDgruMFNVar20b99Q/edit?usp=sharing

Let's Do Some Math!

The colors that you see inside the "[Colorization]" section in your dino exports gives you some information. Lets take a look at it and break it down.

Color Code 30 on Region 0 Example Dino Export:

[Colorization]
ColorSet[0]=(R=0.780000,G=0.700000,B=1.000000,A=0.000000)
ColorSet[1]=(R=0.012500,G=0.050000,B=0.012500,A=0.000000)
ColorSet[2]=(R=0.000000,G=0.000000,B=0.000000,A=1.000000)
ColorSet[3]=(R=0.012500,G=0.050000,B=0.012500,A=0.000000)
ColorSet[4]=(R=0.100000,G=0.075000,B=0.050000,A=0.000000)
ColorSet[5]=(R=0.300000,G=0.240000,B=0.180000,A=0.000000)

There are 5 different values being set on each line.

The first value is what region we're talking about. You can see that by looking at the number inside the square brackets before the equals sign. This refers to the region. We start at 0 due to standard programming syntax when talking about arrays, or multidimensional arrays.

The next set of numbers are going to be the Red, Green, Blue, and Alpha channels of the color. Lets look more specifically at region 0. The following values are being set for each channel. Notice that all these numbers have a value of x.xxxxxx. So each number or "float" has a value up to six decimal places.

Red = 0.780000
Green = 0.700000
Blue = 1.000000
Alpha = 0.000000

So now that we've extracted the values, how do we convert them? Why aren't they already in regular RGB syntax where the value is between 0 and 255? Unreal likes to make things a tad bit complicated for us thats why. If we read up on Linear Color Sets using the Power of 22, which can be found on the Unreal website, we'll notice that the values that are being calculated are actually linear representations of the RGB color scale. So this is a great starting point. Now what.

If you're a PC player you've probably heard of ArkStatsExtractor. This program helps breeders get values from their exported dinos and imports it into their program for parsing and data manipulation. If we look deep into the ArkStatsExtractor code, we'll see this method that defines the formula for getting the single channel value in the correct RGB syntax.

/// <summary>
/// Convert the color definition of the unreal engine to default RGB-values
/// </summary>
/// <param name="lc"></param>
/// <returns></returns>
private static int LinearColorComponentToColorComponentClamped(double lc)
{
  //int v = (int)(255.999f * (lc <= 0.0031308f ? lc * 12.92f : Math.Pow(lc, 1.0f / 2.4f) * 1.055f - 0.055f)); // this formula is only used since UE4.15
  // ARK uses this simplified formula
  int v = (int)(255.999f * Math.Pow(lc, 1f / 2.2f));
  if (v > 255) return 255;
  if (v < 0) return 0;
  return v;
}

So, here's how this method works for those who are not programmatically inclined. The method (also called function) accepts a variable "lc", this value must be of a datatype of double. It then takes that variable and plugs it into the equation or formula. That formula then is going to be one of three things. Higher then 255, lower then 0, or in between or equal to either 255 or 0. Then it returns that value.

So lets look at the actual formula.

// ARK uses this simplified formula
int v = (int)(255.999f * Math.Pow(lc, 1f / 2.2f));

and then lets clean it up and strip away all the C# code so we can then plug in that formula into a workable spreadsheet.

Value = 255.99 * (SingletonValue ^ (1/2.2))

Value is the single channel (Red, Green, or Blue), and the SingletonValue is the Red, Green, or Blue value inside our exported dino .ini file.

So lets plug it into the equation for the red value, blue value, and green value separately.

// Starting String from Exported Dino File
// ColorSet[0]=(R=0.780000,G=0.700000,B=1.000000,A=0.000000)
// --------------------------------------------------------- //
// Red
228.6600852 = 255.999 * 0.780000 ^ (1/2.2)
// Green
217.6848912 = 255.999 * 0.700000 ^ (1/2.2)
// Blue
255.999 = 255.999 * 1.000000 ^ (1/2.2)

So now we've got our values in RGB for each color channel. Lets go ahead and do a quick conversion on this using a Decimal to Hex Converter, and we get the following values.

Red = E4
Green = D9
Blue = FF

This means that for Color ID of 30, we should get the Hexadecimal value or "E4D9FF". Which is the correct color code according to the Wiki.

Summary

I have taken every color code from all the color ID's listed on the wiki, and converted them into true RGB values, and Hexadecimal format for those who want them. Here's a link to my spreadsheet. I have a sheet called Unit Tests, this sheet only had one color fail which was 79, true black. I believe the reason that this failed is due to the fact that in design, particularly digital design, a true #000000 value for black makes things look unreal, and not convincing. The computed value for "TrueBlack" is actually #171717. All other tests for the rest of the 99 colors, have passed.

I hope you guys enjoyed, and had a fun time learning.

Good luck out there and Happy Halloween!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...