herbix / hoi4modutilities

A VSCode extension that contains utilities for Heart of Iron IV mods developers
MIT License
74 stars 9 forks source link

[BUG] Negative RGB values for country colours appear garbled #44

Closed Altarya closed 2 years ago

Altarya commented 2 years ago

Describe the bug Countries with negative RGB values appear garbled.

To Reproduce Set a country's rgb values to be negative

Expected behavior Hoi4 lets you set countries' rgb values to be negative(max -256) so they act as offsets to the engine's post processing, i supposed the expected behaviour here would be for those values to default 0 within the preview.

Screenshots image

Desktop (please complete the following information):

Console Logs Not needed.

herbix commented 2 years ago

I didn't know that country color can have negative values. Can you share me an article that describe how negative color values works?

Altarya commented 2 years ago

I dont think there is a full article with an explanation(I picked this up from other modders) but what they do is they offset the colours the game would have rendered from post processing

For example: You have a country with the colour 255,0,0 However ingame due to post processing it shows up as 255,43,60 Lets say you want that country to show up as 255,0,0 what you would would be to assign its colour code as 255,-43,-60 and thus offsetting the post processing of the game(tho its not universal since post processing depends on your camera distance, position, time of ingame day, and so on).

Since you only use this feature to achieve specific, generally vibrant, colours where one of your rgbs would be 0 its a thing that's rarely used. The solution like I suggested would be to just add a simple check if the rgb values are negative and if yes then set them to 0 for the display.

Altarya commented 2 years ago

Let me explain with some screenshots. Here the tag has the rgb value 255,0,0 image

and here with it set to 255.-255,-255 image

As you can see in the first image the post processing added some colouring to the green and blue channels

herbix commented 2 years ago

Fixed in 0.5.1. Since I can't make it brighter than 255, if there's a -255 it's set to 0. The colour may not be the same as you see in game, but at least it's not garbled now.

Altarya commented 2 years ago

Yup, that works, the preview colours were already always gooing to be a little off due to post processing anyhow, but still serve their purpose as a general indication.

Thanks!