Convert colors to linear RGB in gradient pipelines

This commit is contained in:
Héctor Ramón Jiménez 2022-11-03 04:41:27 +01:00
parent 6246584209
commit 9a02d60ba5
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 13 additions and 12 deletions

View file

@ -86,10 +86,12 @@ impl Program {
for (index, stop) in for (index, stop) in
linear.color_stops.iter().enumerate().take(16) linear.color_stops.iter().enumerate().take(16)
{ {
stops[index * 8] = stop.color.r; let [r, g, b, a] = stop.color.into_linear();
stops[(index * 8) + 1] = stop.color.g;
stops[(index * 8) + 2] = stop.color.b; stops[index * 8] = r;
stops[(index * 8) + 3] = stop.color.a; stops[(index * 8) + 1] = g;
stops[(index * 8) + 2] = b;
stops[(index * 8) + 3] = a;
stops[(index * 8) + 4] = stop.offset; stops[(index * 8) + 4] = stop.offset;
stops[(index * 8) + 5] = 0.; stops[(index * 8) + 5] = 0.;
stops[(index * 8) + 6] = 0.; stops[(index * 8) + 6] = 0.;

View file

@ -168,14 +168,13 @@ impl Pipeline {
let stops: Vec<ColorStop> = linear let stops: Vec<ColorStop> = linear
.color_stops .color_stops
.iter() .iter()
.map(|stop| ColorStop { .map(|stop| {
offset: stop.offset, let [r, g, b, a] = stop.color.into_linear();
color: Vec4::new(
stop.color.r, ColorStop {
stop.color.g, offset: stop.offset,
stop.color.b, color: Vec4::new(r, g, b, a),
stop.color.a, }
),
}) })
.collect(); .collect();