Convert the raster std and adjustments families to element kernels and keep the unit primary's slot

This commit is contained in:
Dennis Kobert
2026-08-23 16:52:43 +00:00
parent 2c15dc838e
commit 511b4da9f5
8 changed files with 326 additions and 256 deletions

View File

@@ -1,8 +1,7 @@
//! Not immediately shader compatible due to needing [`GradientStops`] as a param, which needs [`Vec`]
use crate::adjust::Adjust;
use core_types::list::List;
use core_types::{Color, Ctx};
use core_types::{Color, Ctx, ExtractIndex, InjectIndex};
use raster_types::{CPU, Raster};
use vector_types::GradientStops;
@@ -10,18 +9,21 @@ use vector_types::GradientStops;
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27grdm%27%20%3D%20Gradient%20Map
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=Gradient%20settings%20(Photoshop%206.0)
#[node_macro::node(category("Raster: Adjustment"))]
fn gradient_map<T: Adjust<Color>>(
_: impl Ctx,
fn gradient_map<T: Adjust<Color> + Clone + Send + Sync + core_types::CacheHash + 'static>(
_: impl Ctx + ExtractIndex + InjectIndex + Copy,
#[implementations(
List<Raster<CPU>>,
List<Color>,
List<GradientStops>,
Raster<CPU>,
Color,
GradientStops,
)]
mut image: T,
gradient: List<GradientStops>,
gradient: IList<GradientStops>,
reverse: bool,
) -> T {
let Some(gradient) = gradient.element(0) else { return image };
if gradient.is_empty() {
return image;
}
let gradient = gradient.element_ref(0);
image.adjust(|color| {
let intensity = color.luminance_rec_709();