Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light bg formula is wrong #87

Open
sSolsta opened this issue Aug 13, 2022 · 0 comments
Open

light bg formula is wrong #87

sSolsta opened this issue Aug 13, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@sSolsta
Copy link
Contributor

sSolsta commented Aug 13, 2022

hi so this is something unrelated to my pull request that i found, light bg does NOT use the hsv v value to interpolate but it actually uses the sum of the r, g and b. i did find this in 1.9's code but 2.1 seems to behave identically from my testing.
almost-python pseudocode below for how it actually works, assuming rgb values are 0-255 and hsv's sv values are 0-100:

def lightBG(background: RGB, player1: RGB):
    hsv = background.toHSV()
    hsv.s -= 20 # pretend this is clamped between 0 and 100
    hsv.v += 20 # this too
    lightBG = hsv.toRGB()
    f = (background.r + background.g + background.b) / 150
    if f < 1:
        lightBG.r = lightBG.r * f + player1.r * (1 - f)
        lightBG.g = lightBG.g * f + player1.g * (1 - f)
        lightBG.b = lightBG.b * f + player1.b * (1 - f)
    return rgb

i found the hsv offsets in 1.9's PlayLayer::getLightBGColor and the actual interpolation was done in PlayLayer::updateVisibility, no idea if they're in the same functions in 2.1 though

@Wyliemaster Wyliemaster added the bug Something isn't working label Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants