Skip to content

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

@renjianqiang

Description

@renjianqiang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions