bevy_vox_mesh
bevy_vox_mesh copied to clipboard
Fix incorrect voxel mesh vertex colors
Before
After
Hey, thanks for the fix ! The colors do look better with your changes, however I'm curious whether you have any reference for the gamma function introduced in your changes.
Hello :D,
When we pass a color as raw floats to Bevy, Bevy expects we to pre-convert them to linear, So I just converted the Srgba to LinearRgba, the formula:
$$ \text{linearRGB} = \begin{cases} \frac{\text{sRGB}}{12.92}, & \text{sRGB} \leq 0.04045 \ \left(\frac{\text{sRGB} + 0.055}{1.055}\right)^{2.4}, & \text{sRGB} > 0.04045 \end{cases} $$
See also: https://github.com/bevyengine/bevy/discussions/2783
@yihleego sorry for the very delayed response. Can you reference the linked discussion in a code comment so that this doesn't get lost, this is ready to go afterwards