Posted: Mon Sep 04, 2017 2:03 am Post subject:
Westwood Color Conversion Utility
Subject description: For all your HSV <> RGB conversion needs
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
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. QUICK_EDIT
"Bobingabout made an RGB-to-HSB color converter. Get it here: http://bobingabout.gamemod.net/Files/rgb2hsb.exe " - Colors on ModEnc _________________ 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.
Last edited by TAK02 on Mon Sep 04, 2017 10:32 am; edited 1 time in total QUICK_EDIT
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. QUICK_EDIT
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
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! QUICK_EDIT
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 QUICK_EDIT
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.
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.
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
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