SCS Color converter

Forum rules
SCS as a company do not wish to have paid mods on this forum. While we understand that not all paid mods use the Intellectual Property of other companies/people, it is very hard to moderate what is and isn't acceptable when money is involved. There are also concerns that it could look unfavorable to potential work partners going forward if SCS allow mods that may potentially use unlicensed branding.
Posting in the Mods forum (ATS and ETS2) is restricted to sharing free-to-the-public mods and providing support for mods. For more details, please check the Forum Rules.
dredick
Posts: 99
Joined: 09 Nov 2017 21:18

Re: SCS Color converter

#31 Post by dredick » 26 Oct 2019 12:29

ThatRandomWelshGuy wrote: 09 Jan 2018 20:04 So how exactly do we input the result into the game? Not even Notepad++ can open a .sii file :(
Come again?
User avatar
Smarty
Beta tester
Posts: 1983
Joined: 30 Jun 2015 01:56
Location: Ontario, Canada
Contact:

Re: SCS Color converter

#32 Post by Smarty » 19 Apr 2021 10:18

Oh lovely, Firefox and Edge both block the form from submitting now, even if you disable security. 😶
User avatar
Etrusan
Posts: 651
Joined: 04 Sep 2014 15:29
Location: Brno, Czech Republic
Contact:

Re: SCS Color converter

#33 Post by Etrusan » 19 Apr 2021 11:38

Just convert your scene color profile in GIMP/Photoshop to linear and pick up the color. You don't need any sort of 3rd party converter.
Seasonic SSR-650TD; Intel Core i5-6700K; Gainward GTX 1060 6GB Phoenix GS; 2x Kingston HyperX Fury 8GB; 2x Crucial MX500 2TB; 3x Seagate IronWolf Pro; Corsair Force MP510 960GB; 2x 24" AOC I2481FXH; Windows 10

www.etrusan.net
User avatar
Drive Safely
Posts: 2918
Joined: 20 Jun 2015 06:17
Contact:

Re: SCS Color converter

#34 Post by Drive Safely » 22 Apr 2021 03:26

@Smarty

I feared this would happen so luckily I had my own conversion script saved. Here is a new color converter you can download then open in your browser:

HTML file: https://drive.google.com/file/d/1NOXUrs ... sp=sharing

It doesn't have an online website but you can save it in your File Explorer and keep it working forever. Doesn't need any servers to run since it's fully client-side unlike Dodero's converter.
I kept the user interface familiar because if it ain't broke don't fix it. :) There is also a color picker that for some browsers will let you input RGB or HSL codes as well.

Here is a preview:
[ external image ]
User avatar
vincent123456789016
Posts: 17
Joined: 08 Mar 2021 18:40
Location: The Netherlands

Re: SCS Color converter

#35 Post by vincent123456789016 » 12 Dec 2021 20:50

Drive Safely wrote: 22 Apr 2021 03:26 I feared this would happen so luckily I had my own conversion script saved. Here is a new color converter you can download then open in your browser
shame it only works for converting hex to scs rgb as i am making a paintjob and want to extract the colour from a scs rgb colour code
A Dutch trucksim player that is always looking for more mods to break his game with :lol:.
Languages I speak:
Dutch
English
avenger
Posts: 50
Joined: 07 Feb 2023 13:56

Re: SCS Color converter

#36 Post by avenger » 10 May 2023 03:18

Drive Safely wrote: 22 Apr 2021 03:26 @Smarty

I feared this would happen so luckily I had my own conversion script saved. Here is a new color converter you can download then open in your browser:

HTML file: https://drive.google.com/file/d/1NOXUrs ... sp=sharing

It doesn't have an online website but you can save it in your File Explorer and keep it working forever. Doesn't need any servers to run since it's fully client-side unlike Dodero's converter.
I kept the user interface familiar because if it ain't broke don't fix it. :) There is also a color picker that for some browsers will let you input RGB or HSL codes as well.

Here is a preview:
[ external image ]
Alright thanks, fair enough! The page from this topic is ridden of anti-ad-blocks and ad codes I couldn't even find the actual math it does to convert the codes. What a shame.

From your link, I could easily open the webpage and there's the formula:

Code: Select all

"("+((rgbArray[0]/255) ** 2).toFixed(4) + ", " + ((rgbArray[1]/255) ** 2).toFixed(4) + ", " + ((rgbArray[2]/255) ** 2).toFixed(4)+")";
So, basically, if you have HEX (webcolor) #102030,
1. convert it to decimal (10 => 16, 20 => 32, 30 => 48),
2. divide every value by 255 (I had tried down to this, and as it didn't match, I given up... lol), => 16/255=0.0627450980392157, 32/255=0.1254901960784314, 48/255=0.1882352941176471
3. multiply the value by itself (make it to the power of 2) => (0.0039369473279508, 0.0157477893118032, 0.0354325259515571).

That is, if the formula is right. And in fact, if I convert an hex value using this formula, usually small HEX numbers (like 0x1A) goes back and forth fine, but higher numbers seems to accumulate an error so, say, #881A51 never gets back as it is, but something like #911A59. This suggests the closer the number is to FF (255) the higher is the error. So there's some weight added to the number to make this formula a bit more complex.

Unfortunately after some attempts I couldn't find the exact correction to make this formula precise. I guess that further discussion on that would be worth of a dedicated topic, as the point here is somebody's hosted RGB=>SCSColor calculator.
User avatar
knox_xss
Posts: 1309
Joined: 20 Dec 2012 14:38

Re: SCS Color converter

#37 Post by knox_xss » 10 May 2023 18:48

avenger wrote: 10 May 2023 03:18 And in fact, if I convert an hex value using this formula, usually small HEX numbers (like 0x1A) goes back and forth fine, but higher numbers seems to accumulate an error so, say, #881A51 never gets back as it is, but something like #911A59. This suggests the closer the number is to FF (255) the higher is the error. So there's some weight added to the number to make this formula a bit more complex.
I think these formulas will solve your problem (and problem of all "SCS Color Converters"): https://en.wikipedia.org/wiki/SRGB#Transformation ;)

Example.
Let's take RGB = 235 (R = G = B = 235). In HEX 235 will be "EB". It's clear. Okay.
[ external image ] [ external image ]

According to "SCS Color Converter", this #EBEBEB will be "(0.8493, 0.8493, 0.8493)"... and this is wrong, because (see base_color):

Code: Select all

SiiNunit
{
accessory_paint_job_data : color.scs.box.paint_job
{
	name: "Crystal White"
	price: 2600
	unlock: 5
	base_color: (0.8307, 0.8307, 0.8307)
	base_color_locked: true
	stock: true
	part_type: aftermarket
}
} 
Let's try to encode via sRGB Transformations manually...

We have color 235.
Let f denote a fractional (from the word "float") number.

We encode "directly" (according to the upper formula).
f = 235 / 255 = 0.92156862745098039215686274509804.
The number f turned out to be greater than 0.04045, so we consider this: ((f + 0.055) / 1.055) and then raise it to the power of 2.4.
We get: 0.83076987677465456326680486629645. That is as in def.

We encode "inversely" (according to the lower formula).
Number f = 0.8307 (taken from def).
We have a number f greater than 0.0031308, so we consider this: we raise f to the power (1/2.4), then multiply by 1.055, then subtract 0.055.
We get: 0.92153440159716157976920448100598. Multiplying it by 255, we get 234.99127240727620284114714265653, i.e., rounded up, 235.

_______________

You can also use this Online Color Converter: https://ajalt.github.io/colormath/converter/
In the "Convert from:" choose "sRGB (0-255)", and look in the table for the value "Linear sRGB" - it also gives the right numbers for us (0.83077, 0.83077, 0.83077). ;)
Long way to Fuji starts with the first step!
User avatar
Drive Safely
Posts: 2918
Joined: 20 Jun 2015 06:17
Contact:

Re: SCS Color converter

#38 Post by Drive Safely » 10 May 2023 23:37

@knox_xss - Thanks very much for the information to make it more precise. That's a great explanation. I've included the formula in my version of the SCS Color Converter now.

Of course to get even more precision you can increase the number of decimal places. In the script you can replace if you want ".toFixed(4)", where 4 is the number of decimal places. But 4 decimal places is enough for me. :)

@avenger - I've updated my version with the more precise formula above. Re-download to get it. Hopefully I didn't break anything but it appears to calculate more precisely now for those higher numbers. :)
User avatar
knox_xss
Posts: 1309
Joined: 20 Dec 2012 14:38

Re: SCS Color converter

#39 Post by knox_xss » 11 May 2023 10:51

@Drive Safely Sorry, man, but your code is slightly wrong...

Code: Select all

	var r = rgbArray[0]/255;
	if(r > 0.04045) {
		r = (r + 0.055) / 1.055;
		r = r ** 2.4;
	}
	else {
		r = r ** 2;
	}
I pointed out where to look for the formula. Why invent something of your own, if there is an exact formula?.. :)
[ external image ]

And according to the formula, it should be like this:

Code: Select all

	else {
		r = r / 12.92;
	}
And according to next formula, you could do the reverse transformation - from SCS to RGB... ;)
[ external image ]
Long way to Fuji starts with the first step!
User avatar
Drive Safely
Posts: 2918
Joined: 20 Jun 2015 06:17
Contact:

Re: SCS Color converter

#40 Post by Drive Safely » 11 May 2023 20:58

@knox_xss - Thanks, I added the corrections.

Raising to the power of 2 was long speculated as part of the approximate formula, as seen here, but clearly we know where the formula is now.
Post Reply

Return to “Others”

Who is online

Users browsing this forum: edu011942 and 17 guests