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

Encoding normalized floats to RGBA8 vectors - maybe divide by 255 instead of 256 #4

Open
renjianqiang opened this issue Dec 8, 2021 · 0 comments

Comments

@renjianqiang
Copy link

renjianqiang commented Dec 8, 2021

Hi, i think there is a problem in your article "Encoding normalized floats to RGBA8 vectors".

For example, there is a float number 0.545, and run packFloatToVec4i will get the vec4 [0.7200000006705523, 0.1171875, 0.51953125, 0.54296875], then multiply vec4 by 255.0 can get the [183.60000017099082, 29.8828125, 132.48046875, 138.45703125] according to this article, finally, the color will round to integer and the error is introduced.

At last we will get the wrong float number when run unpackFloatFromVec4i in shader. So, the divisor should be 255.0.

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

No branches or pull requests

1 participant