bevy_vox_mesh icon indicating copy to clipboard operation
bevy_vox_mesh copied to clipboard

Fix incorrect voxel mesh vertex colors

Open yihleego opened this issue 8 months ago • 3 comments
trafficstars

Before

2025-03-20 12 19 23

After

2025-03-20 12 18 13

yihleego avatar Mar 20 '25 04:03 yihleego

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.

Game4all avatar Mar 20 '25 09:03 Game4all

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 avatar Mar 20 '25 11:03 yihleego

@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

Game4all avatar Mar 25 '25 11:03 Game4all