bevy_webgl2
bevy_webgl2 copied to clipboard
Colors rendered differently compared to bevy default renderer
I've tried to render simple mesh with vertex colors:
mesh.set_attribute(Mesh::ATTRIBUTE_COLOR, vec![[0.7, 0.2, 0.2]; buffers.vertices.len()]);
and looks like webgl2 in this case interprets color as sRGB, and bevy as linearRGB
using same code in both (left is web):
but if in native version I convert color from sRGB to linear first, then result color will be the same
let color = Color::rgb(0.7, 0.2, 0.2).as_linear_rgba_f32();
mesh.set_attribute(
Mesh::ATTRIBUTE_COLOR,
vec![[color[0], color[1], color[2]]; buffers.vertices.len()],
);