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

Fix .arm reading issue when world color exceeds [0, 1] range #2656

Merged
merged 1 commit into from
Nov 12, 2022

Conversation

MoritzBrueckner
Copy link
Collaborator

This PR fixes #2650.

arm.utils.color_to_int() is meant to convert a 4-component color into a 32 bit integer value (for direct use as kha.Color*) but it could happen that the resulting value was bigger than that. As a result, the integer would be exported as unsigned 64 bit in the .arm file and because the reader in Iron currently does not implement this (0xcf prefix) the parser returned a wrong result.

Haxe still doesn't seem to have a UInt64 type on all targets, and even the Int64 type is simulated on some platforms IIRC. Armory doesn't seem to use them at the moment, but should we still read two 32 bit integers in case of 64 bit numbers and output a garbage value just to make sure that the parser can continue correctly (+ output a warning)? It's then easier in the future to find any similar issues. I'm also not sure btw if the uint32 case is correctly implemented (it's using readInt32()), but I don't know of any issues with that.

* this is why we can clamp the function's input value, it's only used for background clearing on the forward RP. Converting the return value into a 32 bit int would introduce overflow situations.

@luboslenco luboslenco merged commit 325f314 into armory3d:main Nov 12, 2022
@luboslenco
Copy link
Member

Thanks!

Armory doesn't seem to use them at the moment

If it's not used at the moment maybe we can raise a flag directly during export at https://github.com/armory3d/armory/blob/main/blender/arm/lib/armpack.py#L51.

@MoritzBrueckner MoritzBrueckner deleted the fix-world-color-export branch November 17, 2022 20:22
@MoritzBrueckner MoritzBrueckner added the Release Notes: Fixes A pull request that fixes something. Used to generate release notes. label Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release Notes: Fixes A pull request that fixes something. Used to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If scene world color value is higher than 1.0; Armory breaks
2 participants