mrk-its / bevy_webgl2

WebGL2 renderer plugin for Bevy game engine
MIT License
172 stars 46 forks source link

Colors rendered differently compared to bevy default renderer #51

Open rsk700 opened 2 years ago

rsk700 commented 2 years ago

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): same

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()],
);

to_linear