mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 00:38:11 +08:00
Reenable hue saturation node for compilation
This commit is contained in:
committed by
Keavon Chambers
parent
59e70cd812
commit
fea9f8ea24
@@ -321,31 +321,30 @@ fn grayscale_color_node(color: Color, tint: Color, reds: f64, yellows: f64, gree
|
|||||||
color.to_linear_srgb()
|
color.to_linear_srgb()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HueSaturationNode<Hue, Saturation, Lightness> {
|
||||||
|
hue_shift: Hue,
|
||||||
|
saturation_shift: Saturation,
|
||||||
|
lightness_shift: Lightness,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[node_macro::node_fn(HueSaturationNode)]
|
||||||
pub struct HueSaturationNode<Hue, Saturation, Lightness> {
|
fn hue_shift_color_node(color: Color, hue_shift: f64, saturation_shift: f64, lightness_shift: f64) -> Color {
|
||||||
hue_shift: Hue,
|
let color = color.to_gamma_srgb();
|
||||||
saturation_shift: Saturation,
|
|
||||||
lightness_shift: Lightness,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[node_macro::node_fn(HueSaturationNode)]
|
let [hue, saturation, lightness, alpha] = color.to_hsla();
|
||||||
fn hue_shift_color_node(color: Color, hue_shift: f64, saturation_shift: f64, lightness_shift: f64) -> Color {
|
|
||||||
let color = color.to_gamma_srgb();
|
|
||||||
|
|
||||||
let [hue, saturation, lightness, alpha] = color.to_hsla();
|
let color = Color::from_hsla(
|
||||||
|
(hue + hue_shift as f32 / 360.) % 1.,
|
||||||
|
// TODO: Improve the way saturation works (it's slightly off)
|
||||||
|
(saturation + saturation_shift as f32 / 100.).clamp(0., 1.),
|
||||||
|
// TODO: Fix the way lightness works (it's very off)
|
||||||
|
(lightness + lightness_shift as f32 / 100.).clamp(0., 1.),
|
||||||
|
alpha,
|
||||||
|
);
|
||||||
|
|
||||||
let color = Color::from_hsla(
|
color.to_linear_srgb()
|
||||||
(hue + hue_shift as f32 / 360.) % 1.,
|
}
|
||||||
// TODO: Improve the way saturation works (it's slightly off)
|
|
||||||
(saturation + saturation_shift as f32 / 100.).clamp(0., 1.),
|
|
||||||
// TODO: Fix the way lightness works (it's very off)
|
|
||||||
(lightness + lightness_shift as f32 / 100.).clamp(0., 1.),
|
|
||||||
alpha,
|
|
||||||
);
|
|
||||||
|
|
||||||
color.to_linear_srgb()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct InvertRGBNode;
|
pub struct InvertRGBNode;
|
||||||
|
|||||||
@@ -215,9 +215,10 @@ pub fn compile(dir: &Path) -> Result<spirv_builder::CompileResult, spirv_builder
|
|||||||
.preserve_bindings(true)
|
.preserve_bindings(true)
|
||||||
.release(true)
|
.release(true)
|
||||||
.spirv_metadata(SpirvMetadata::Full)
|
.spirv_metadata(SpirvMetadata::Full)
|
||||||
//.extra_arg("no-early-report-zombies")
|
.capability(spirv_builder::Capability::Float64)
|
||||||
//.extra_arg("no-infer-storage-classes")
|
.extra_arg("no-early-report-zombies")
|
||||||
//.extra_arg("spirt-passes=qptr")
|
.extra_arg("no-infer-storage-classes")
|
||||||
|
.extra_arg("spirt-passes=qptr")
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|||||||
@@ -670,7 +670,7 @@ impl NodeNetwork {
|
|||||||
// replace value inputs with value nodes
|
// replace value inputs with value nodes
|
||||||
for input in &mut node.inputs {
|
for input in &mut node.inputs {
|
||||||
// Skip inputs that are already value nodes
|
// Skip inputs that are already value nodes
|
||||||
if node.implementation == DocumentNodeImplementation::Unresolved("graphene_core::value::ValueNode".into()) {
|
if node.implementation == DocumentNodeImplementation::Unresolved("graphene_core::value::ClonedNode".into()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ impl NodeNetwork {
|
|||||||
DocumentNode {
|
DocumentNode {
|
||||||
name: "Value".into(),
|
name: "Value".into(),
|
||||||
inputs: vec![NodeInput::Value { tagged_value, exposed }],
|
inputs: vec![NodeInput::Value { tagged_value, exposed }],
|
||||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::ValueNode".into()),
|
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::ClonedNode".into()),
|
||||||
path,
|
path,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -844,7 +844,7 @@ impl NodeNetwork {
|
|||||||
assert_eq!(output_index, 0);
|
assert_eq!(output_index, 0);
|
||||||
// TODO: check if we can readd lambda checking
|
// TODO: check if we can readd lambda checking
|
||||||
let mut input_node = self.nodes.remove(&node_id).unwrap();
|
let mut input_node = self.nodes.remove(&node_id).unwrap();
|
||||||
node.implementation = DocumentNodeImplementation::Unresolved("graphene_core::value::ValueNode".into());
|
node.implementation = DocumentNodeImplementation::Unresolved("graphene_core::value::ClonedNode".into());
|
||||||
if let Some(input) = input_node.inputs.get_mut(0) {
|
if let Some(input) = input_node.inputs.get_mut(0) {
|
||||||
*input = NodeInput::Network(input.ty());
|
*input = NodeInput::Network(input.ty());
|
||||||
}
|
}
|
||||||
@@ -1119,7 +1119,7 @@ mod test {
|
|||||||
tagged_value: TaggedValue::U32(2),
|
tagged_value: TaggedValue::U32(2),
|
||||||
exposed: false,
|
exposed: false,
|
||||||
}],
|
}],
|
||||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::ValueNode".into()),
|
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::ClonedNode".into()),
|
||||||
path: Some(vec![1, 4]),
|
path: Some(vec![1, 4]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ impl<'a> TaggedValue {
|
|||||||
TaggedValue::F64(x) => x.to_string() + "_f64",
|
TaggedValue::F64(x) => x.to_string() + "_f64",
|
||||||
TaggedValue::Bool(x) => x.to_string(),
|
TaggedValue::Bool(x) => x.to_string(),
|
||||||
TaggedValue::BlendMode(blend_mode) => "BlendMode::".to_string() + &blend_mode.to_string(),
|
TaggedValue::BlendMode(blend_mode) => "BlendMode::".to_string() + &blend_mode.to_string(),
|
||||||
|
TaggedValue::Color(color) => "graphene_core::Color::from_rgbaf32_unchecked(0.,0.,0.,1.)".to_string(),
|
||||||
_ => panic!("Cannot convert to primitive string"),
|
_ => panic!("Cannot convert to primitive string"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user