Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Thu Mar 28, 2024 2:40 pm
All times are UTC + 0
Westwood Color Conversion Utility
Moderators: Community Tools Developpers
Post new topic   Reply to topic Page 1 of 1 [11 Posts] Mark the topic unread ::  View previous topic :: View next topic
Author Message
tomsons26lv
Cyborg Artillery


Joined: 30 Dec 2009
Location: Latvia

PostPosted: Mon Sep 04, 2017 2:03 am    Post subject:  Westwood Color Conversion Utility
Subject description: For all your HSV <> RGB conversion needs
Reply with quote  Mark this post and the followings unread

I always wanted a RGB2HSV tool that can convert to the ranges Westwood used which are 255 255 255 instead of the standard 360 255 255, that isn't a utter pile of gigantic crap covered smoldering trash like RGB2HSV in Npatch.

I recently managed to reverse engineer the original functions RA used for these conversions, i patched them in RA to check if the outputs match and they did.
So with little delay i started working on this tool.

After some frustrations with WinForms here it is.
Written in C# cause i figured it gives more portability being able to run with Mono, linux and what not, and a smaller app. Its compiled with .Net 2.0 so should work on even a potato.
So finally anyone can reliably adjust the HSV colors in rules.


There is a slight difference from what's going on in game however.

This tool is more precise cause the game uses 6-bit colors and scales them up to 8, meaning the max value for RGB is 63 63 63, when feed to the original RGB2HSV function it does a (value >> 6) | (value << 2) meaning it scales that to the 255 range, when feed to HSV2RGB afterwards it scales it back down to the 6-bit range.
But the difference is ~3 values max so it should be insignificant, i just didn't feel the need to complicate coding it with this little difference.

You might ask what makes it "Westwood" reason is WW used a custom HSV model, this code is literally like nothing on the web, even if you find seemingly properly working HSV code that converts to the 255 range its output won't 100% or even 75% match Westwood's



WWColorUtil_2017-09-04_05-10-20.png
 Description:
 Filesize:  19.17 KB
 Viewed:  5136 Time(s)

WWColorUtil_2017-09-04_05-10-20.png



WWColorUtil.zip
 Description:

Download
 Filename:  WWColorUtil.zip
 Filesize:  5.76 KB
 Downloaded:  320 Time(s)


_________________
Tiberian Dawn, Red Alert, Tiberian Sun ,Red Alert 2,Renegade, Command & Conquer 3,Tiberium and Tiberium Wars and Westwood related image & video archive
https://picasaweb.google.com/113361105083292812413?noredirect=1

Skype live:tomsons26
Don't forget to state who are you otherwise i'll ignore the invite

Back to top
View user's profile Send private message Visit poster's website
deathreaperz
Commander


Joined: 20 May 2013
Location: Indonesia

PostPosted: Mon Sep 04, 2017 5:18 am    Post subject: Reply with quote  Mark this post and the followings unread

This is amazing.

_________________
Quote:
Humans were born for two things: to pray and be productive.


Back to top
View user's profile Send private message
E1 Elite
General


Joined: 28 May 2013

PostPosted: Mon Sep 04, 2017 5:37 am    Post subject: Reply with quote  Mark this post and the followings unread

There is a difference of 15-20 in saturation and 5-10 in value/lumination
compared to what the game uses. The inaccuracy is more than the rounding
off like 255 is 252 in-game which uses multiples of 4.

Testing with TS:

Using in-game screenshot feature Ctrl+C (default) for screenshot, it gives
pcx file in game folder. This avoids any gamma/color settings on Windows/
graphics driver. RGB values could be found out from these screenshots.

Comparing with the colors not affected by the map ambient lightings, like
using the text colors of Options/Credits and labels on sidebar icons. Under
section [Colors] in rules.ini, LightGold is used for TopBar - Options, Credit
amount and LightGrey is used for sidebar Cameo Text and Queue Count.
These HSV values in rules.ini can be modified to get exactly what RGB
colors is used by the game.

RA could be slightly different from TS. I haven't tested RA/RA2.

Back to top
View user's profile Send private message
TAK02
General


Joined: 28 Jun 2015
Location: It was Damascus.

PostPosted: Mon Sep 04, 2017 8:01 am    Post subject: Reply with quote  Mark this post and the followings unread


_________________
One and only developer of the Command & Conquer Dune "C&C D" mod.
m7 wrote:
I tend to release things I create so that assets are never lost to hard drive problems, accidental deletion, or me having to pretend to care about rippers taking things from my project when it is done. #Tongue

Last edited by TAK02 on Mon Sep 04, 2017 10:32 am; edited 1 time in total

Back to top
View user's profile Send private message Send e-mail Visit poster's website ModDB Profile ID YouTube User URL Twitter Channel URL Skype Account
Blade
Cyborg Commando


Joined: 23 Dec 2003

PostPosted: Mon Sep 04, 2017 10:15 am    Post subject: Reply with quote  Mark this post and the followings unread

I believe the TS code uses floating point maths for its conversion rather than bit shifting fixed point maths so its precision will vary slightly from this and this could theoretically account for the variation.

Back to top
View user's profile Send private message
tomsons26lv
Cyborg Artillery


Joined: 30 Dec 2009
Location: Latvia

PostPosted: Mon Sep 04, 2017 11:19 am    Post subject: Reply with quote  Mark this post and the followings unread

TAK02 wrote:
"Bobingabout made an RGB-to-HSB color converter. Get it here: http://bobingabout.gamemod.net/Files/rgb2hsb.exe " - Colors on ModEnc

It's a variation of the same thing shipped with NPatch and its 3 other spawns, all equally incorrect.

E1 Elite wrote:
There is a difference of 15-20 in saturation and 5-10 in value/lumination
compared to what the game uses. The inaccuracy is more than the rounding
off like 255 is 252 in-game which uses multiples of 4.

Testing with TS:

Using in-game screenshot feature Ctrl+C (default) for screenshot, it gives
pcx file in game folder. This avoids any gamma/color settings on Windows/
graphics driver. RGB values could be found out from these screenshots.

Comparing with the colors not affected by the map ambient lightings, like
using the text colors of Options/Credits and labels on sidebar icons. Under
section [Colors] in rules.ini, LightGold is used for TopBar - Options, Credit
amount and LightGrey is used for sidebar Cameo Text and Queue Count.
These HSV values in rules.ini can be modified to get exactly what RGB
colors is used by the game.

RA could be slightly different from TS. I haven't tested RA/RA2.

Hmm, thanks for checking this out, ill do some testing, maybe if i figure out how to do the bit shifting while still allowing the user to input the full ranges add it as maybe a toggle checkbox.

EDIT:
Ok redo your tests in fullscreen mode, windowed mode alters the colors quite a lot.



palette.png
 Description:
Original image that was converted with WW's Shapeset
 Filesize:  7.94 KB
 Viewed:  5083 Time(s)

palette.png



gamemd-spawn_2017-09-04_15-11-00.png
 Description:
Fullscreen
 Filesize:  89.48 KB
 Viewed:  5083 Time(s)

gamemd-spawn_2017-09-04_15-11-00.png



gamemd-spawn_2017-09-04_15-08-59.png
 Description:
Windowed
 Filesize:  105.94 KB
 Viewed:  5083 Time(s)

gamemd-spawn_2017-09-04_15-08-59.png



_________________
Tiberian Dawn, Red Alert, Tiberian Sun ,Red Alert 2,Renegade, Command & Conquer 3,Tiberium and Tiberium Wars and Westwood related image & video archive
https://picasaweb.google.com/113361105083292812413?noredirect=1

Skype live:tomsons26
Don't forget to state who are you otherwise i'll ignore the invite

Back to top
View user's profile Send private message Visit poster's website
E1 Elite
General


Joined: 28 May 2013

PostPosted: Mon Sep 04, 2017 1:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

The values didn't change in windowed/fullscreen modes.

Examples:

HSV in rules - RGB in-game - RGB this tool
0 0 220 - 208 212 208 - 220 220 220
34 128 255 - 248 228 152 - 255 230 127
98 75 255 - 192 248 208 - 180 255 203
216 228 255 - 248 76 232 - 255 27 237
70 245 225 - 112 216 56 - 97 255 10
200 235 170 - 128 44 160 - 124 13 170
85 235 150 - 40 144 40 - 11 150 11

Bobingabout and pd tool results are very similar to this tool. May be the
game matches the color to some nearest color in some internal palette!

Back to top
View user's profile Send private message
tomsons26lv
Cyborg Artillery


Joined: 30 Dec 2009
Location: Latvia

PostPosted: Mon Sep 04, 2017 7:54 pm    Post subject: Reply with quote  Mark this post and the followings unread

E1 Elite wrote:
The values didn't change in windowed/fullscreen modes.

Examples:

HSV in rules - RGB in-game - RGB this tool
0 0 220 - 208 212 208 - 220 220 220
34 128 255 - 248 228 152 - 255 230 127
98 75 255 - 192 248 208 - 180 255 203
216 228 255 - 248 76 232 - 255 27 237
70 245 225 - 112 216 56 - 97 255 10
200 235 170 - 128 44 160 - 124 13 170
85 235 150 - 40 144 40 - 11 150 11

Bobingabout and pd tool results are very similar to this tool. May be the
game matches the color to some nearest color in some internal palette!

Looks like something like that is going on, i just tested the shifts RA does in Excel, it really is a 3 value difference as HSV 0 0 220 is 220 220 220 in RGB, that's obvious without code.
Yea so this will be output as it's in the function itself, no clue if the loss that's visually ingame can be emulated.

_________________
Tiberian Dawn, Red Alert, Tiberian Sun ,Red Alert 2,Renegade, Command & Conquer 3,Tiberium and Tiberium Wars and Westwood related image & video archive
https://picasaweb.google.com/113361105083292812413?noredirect=1

Skype live:tomsons26
Don't forget to state who are you otherwise i'll ignore the invite

Back to top
View user's profile Send private message Visit poster's website
E1 Elite
General


Joined: 28 May 2013

PostPosted: Tue Sep 05, 2017 1:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

To get from HSV 0 0 220 to RGB 208 212 208, brightness value should be
around 83% rather than 86-87% which makes 220. Also it might be using
RGB 5:6:5 format for conversion.

Edit:

More examples for precision test

HSV in rules -> RGB in game:

0 0 213 -> 200 204 200
0 0 (214 to 217) -> 208 208 208
0 0 (218 to 221) -> 208 212 208
0 0 222 -> 216 216 216

85 96 220 -> 152 212 152
85 (97 to 109) 220 -> 144 212 144
85 110 220 -> 136 212 136

83 100 220 -> 152 212 144
(84 to 86) 100 220 -> 144 212 144
87 100 220 -> 144 212 152

Back to top
View user's profile Send private message
TAK02
General


Joined: 28 Jun 2015
Location: It was Damascus.

PostPosted: Sat Sep 09, 2017 6:12 am    Post subject: Reply with quote  Mark this post and the followings unread

tomsons26lv wrote:
TAK02 wrote:
"Bobingabout made an RGB-to-HSB color converter. Get it here: http://bobingabout.gamemod.net/Files/rgb2hsb.exe " - Colors on ModEnc

It's a variation of the same thing shipped with NPatch and its 3 other spawns, all equally incorrect.


Eh? And what exactly is that supposed to mean? That the colors won't show up correctly in-game as they do in the program?
the ColorConverster was meant for RGB2HSV, and works correctly, even with more... exotic colors.

_________________
One and only developer of the Command & Conquer Dune "C&C D" mod.
m7 wrote:
I tend to release things I create so that assets are never lost to hard drive problems, accidental deletion, or me having to pretend to care about rippers taking things from my project when it is done. #Tongue

Back to top
View user's profile Send private message Send e-mail Visit poster's website ModDB Profile ID YouTube User URL Twitter Channel URL Skype Account
tomsons26lv
Cyborg Artillery


Joined: 30 Dec 2009
Location: Latvia

PostPosted: Sat Sep 09, 2017 11:20 am    Post subject: Reply with quote  Mark this post and the followings unread

TAK02 wrote:
tomsons26lv wrote:
TAK02 wrote:
"Bobingabout made an RGB-to-HSB color converter. Get it here: http://bobingabout.gamemod.net/Files/rgb2hsb.exe " - Colors on ModEnc

It's a variation of the same thing shipped with NPatch and its 3 other spawns, all equally incorrect.


Eh? And what exactly is that supposed to mean? That the colors won't show up correctly in-game as they do in the program?
the ColorConverster was meant for RGB2HSV, and works correctly, even with more... exotic colors.

They were wrong against the one test app that does HSV255 i found, finally found the screenshot of it, seems i was wrong, the test app is the bugged one seems rgb2hsb also uses WW's code, welp at least mine is easier to use



ColorWheelHSV_2017-02-16_13-59-40.png
 Description:
 Filesize:  72.44 KB
 Viewed:  4899 Time(s)

ColorWheelHSV_2017-02-16_13-59-40.png



_________________
Tiberian Dawn, Red Alert, Tiberian Sun ,Red Alert 2,Renegade, Command & Conquer 3,Tiberium and Tiberium Wars and Westwood related image & video archive
https://picasaweb.google.com/113361105083292812413?noredirect=1

Skype live:tomsons26
Don't forget to state who are you otherwise i'll ignore the invite

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [11 Posts] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
Quick Reply
Username:


If you are visually impaired or cannot otherwise answer the challenges below please contact the Administrator for help.


Write only two of the following words separated by a sharp: Brotherhood, unity, peace! 

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © phpBB Group

[ Time: 0.1993s ][ Queries: 18 (0.0147s) ][ Debug on ]