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

Improve calculation of light colors #1967

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

Jaklyy
Copy link
Contributor

@Jaklyy Jaklyy commented Jan 29, 2024

Edit: This pr improves the algorithm for diffuse lighting to be (near?) perfect, thanks to discoveries by asuza.
This also changes the way fractional color precision is handled to be maintained until all lights are calculated.

Previous text:
Fixes #1966
Results in lighting being noticeably brighter when multiple lights are enabled.
Colors seem to match hardware better.
Doesn't appear to be perfect, though it's possible those imperfections are due to inaccurate interpolation rather than problems with the lighting calc itself.
Definitely needs some test rom verification, though.

Before:
image
After:
image
HW Capture (frame dump "reconstructed full color" screenshot):
image

@Jaklyy
Copy link
Contributor Author

Jaklyy commented Jan 29, 2024

messing with a test rom reveals that there's definitely still something ever so slightly off in the color calcs
but it seems to overall be much closer to hardware

shouldn't need to check that every time, since the variable shouldn't be able to overflow
Should it cap at all?
Can vtx colors overflow...?
@Jaklyy Jaklyy force-pushed the lighting-test branch 2 times, most recently from 4f45a03 to 5ae9ed6 Compare February 8, 2024 15:08
fixes some minor inaccuracies
@Jaklyy
Copy link
Contributor Author

Jaklyy commented Feb 9, 2024

Emissive and Ambient lighting are pixel perfect.
Diffuse light should be pixel perfect (minus overflow behavior)
Specular still needs work.

Updated Lugia:
image

@Jaklyy Jaklyy changed the title Maintain fractional color precision until all lights are calculated Improve calculation of light colors Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lighting inaccuracy on pkmn:ss title screen
1 participant