Remove Oklab gradient support

This commit is contained in:
Héctor Ramón Jiménez 2025-08-23 21:13:54 +02:00
parent 7d72b9135d
commit f9a6a3051d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 20 additions and 88 deletions

View file

@ -72,8 +72,6 @@ impl Pipeline {
) -> Self {
#[cfg(not(target_arch = "wasm32"))]
{
use crate::graphics::color;
let layout = device.create_pipeline_layout(
&wgpu::PipelineLayoutDescriptor {
label: Some("iced_wgpu.quad.gradient.pipeline"),
@ -86,39 +84,17 @@ impl Pipeline {
device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("iced_wgpu.quad.gradient.shader"),
source: wgpu::ShaderSource::Wgsl(
std::borrow::Cow::Borrowed(
if color::GAMMA_CORRECTION {
concat!(
include_str!("../shader/quad.wgsl"),
"\n",
include_str!("../shader/vertex.wgsl"),
"\n",
include_str!(
"../shader/quad/gradient.wgsl"
),
"\n",
include_str!("../shader/color.wgsl"),
"\n",
include_str!("../shader/color/oklab.wgsl")
)
} else {
concat!(
include_str!("../shader/quad.wgsl"),
"\n",
include_str!("../shader/vertex.wgsl"),
"\n",
include_str!(
"../shader/quad/gradient.wgsl"
),
"\n",
include_str!("../shader/color.wgsl"),
"\n",
include_str!(
"../shader/color/linear_rgb.wgsl"
)
)
},
),
std::borrow::Cow::Borrowed(concat!(
include_str!("../shader/quad.wgsl"),
"\n",
include_str!("../shader/vertex.wgsl"),
"\n",
include_str!("../shader/quad/gradient.wgsl"),
"\n",
include_str!("../shader/color.wgsl"),
"\n",
include_str!("../shader/color/linear_rgb.wgsl")
)),
),
});

View file

@ -1,23 +0,0 @@
const to_lms = mat3x4<f32>(
vec4<f32>(0.4121656120, 0.2118591070, 0.0883097947, 0.0),
vec4<f32>(0.5362752080, 0.6807189584, 0.2818474174, 0.0),
vec4<f32>(0.0514575653, 0.1074065790, 0.6302613616, 0.0),
);
const to_rgb = mat3x4<f32>(
vec4<f32>( 4.0767245293, -3.3072168827, 0.2307590544, 0.0),
vec4<f32>(-1.2681437731, 2.6093323231, -0.3411344290, 0.0),
vec4<f32>(-0.0041119885, -0.7034763098, 1.7068625689, 0.0),
);
fn interpolate_color(from_: vec4<f32>, to_: vec4<f32>, factor: f32) -> vec4<f32> {
// To Oklab
let lms_a = pow(from_ * to_lms, vec3<f32>(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0));
let lms_b = pow(to_ * to_lms, vec3<f32>(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0));
let mixed = mix(lms_a, lms_b, factor);
// Back to linear RGB
var color = to_rgb * (mixed * mixed * mixed);
return color;
}

View file

@ -827,7 +827,6 @@ mod solid {
mod gradient {
use crate::Buffer;
use crate::graphics::Antialiasing;
use crate::graphics::color;
use crate::graphics::mesh;
use crate::triangle;
@ -922,35 +921,15 @@ mod gradient {
device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("iced_wgpu.triangle.gradient.shader"),
source: wgpu::ShaderSource::Wgsl(
std::borrow::Cow::Borrowed(
if color::GAMMA_CORRECTION {
concat!(
include_str!("shader/triangle.wgsl"),
"\n",
include_str!(
"shader/triangle/gradient.wgsl"
),
"\n",
include_str!("shader/color.wgsl"),
"\n",
include_str!("shader/color/oklab.wgsl")
)
} else {
concat!(
include_str!("shader/triangle.wgsl"),
"\n",
include_str!(
"shader/triangle/gradient.wgsl"
),
"\n",
include_str!("shader/color.wgsl"),
"\n",
include_str!(
"shader/color/linear_rgb.wgsl"
)
)
},
),
std::borrow::Cow::Borrowed(concat!(
include_str!("shader/triangle.wgsl"),
"\n",
include_str!("shader/triangle/gradient.wgsl"),
"\n",
include_str!("shader/color.wgsl"),
"\n",
include_str!("shader/color/linear_rgb.wgsl")
)),
),
});