Shaders: graster-nodes no-std prep (#2924)

* raster-nodes: remove commented out index node

* raster-nodes: move `CubicSplines` to separate mod

* raster-nodes: create `mod blending_nodes` and move assoc nodes

* raster-nodes: move node `gradient_map` to its own mod
This commit is contained in:
Firestar99
2025-07-24 15:32:10 +02:00
committed by GitHub
parent 59f3835c5d
commit e7b8b5a3b6
9 changed files with 426 additions and 421 deletions

View File

@@ -0,0 +1,30 @@
//! Not immediately shader compatible due to needing [`GradientStops`] as a param, which needs [`Vec`]
use crate::adjust::Adjust;
use graphene_core::gradient::GradientStops;
use graphene_core::raster_types::{CPU, RasterDataTable};
use graphene_core::{Color, Ctx};
// Aims for interoperable compatibility with:
// 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"))]
async fn gradient_map<T: Adjust<Color>>(
_: impl Ctx,
#[implementations(
Color,
RasterDataTable<CPU>,
GradientStops,
)]
mut image: T,
gradient: GradientStops,
reverse: bool,
) -> T {
image.adjust(|color| {
let intensity = color.luminance_srgb();
let intensity = if reverse { 1. - intensity } else { intensity };
gradient.evaluate(intensity as f64).to_linear_srgb()
});
image
}