From 1d9b9fda1efca7e08e4175856fb9dd75692f1bfd Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 15 Dec 2024 21:04:32 +0200 Subject: [PATCH] Add color curves layer effect --- src/Classes/ShaderLoader.gd | 11 +++++++++++ src/UI/Nodes/CurveEditor/CurveEdit.gd | 6 ++++++ src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd | 1 + 3 files changed, 18 insertions(+) diff --git a/src/Classes/ShaderLoader.gd b/src/Classes/ShaderLoader.gd index 495bc5c46..a154ccfe8 100644 --- a/src/Classes/ShaderLoader.gd +++ b/src/Classes/ShaderLoader.gd @@ -252,6 +252,17 @@ static func create_ui_for_shader_uniforms( func(_gradient, _cc): value_changed.call(gradient_edit.texture, u_name) ) hbox.add_child(gradient_edit) + elif u_name.begins_with("curve_"): + var curve_edit := CurveEdit.new() + curve_edit.size_flags_horizontal = Control.SIZE_EXPAND_FILL + if params.has(u_name) and params[u_name] is CurveTexture: + curve_edit.curve = params[u_name].curve + else: + curve_edit.set_default_curve() + curve_edit.value_changed.connect( + func(curve: Curve): value_changed.call(CurveEdit.to_texture(curve), u_name) + ) + hbox.add_child(curve_edit) else: ## Simple texture var file_dialog := FileDialog.new() file_dialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE diff --git a/src/UI/Nodes/CurveEditor/CurveEdit.gd b/src/UI/Nodes/CurveEditor/CurveEdit.gd index e7c4ef154..d3163dd40 100644 --- a/src/UI/Nodes/CurveEditor/CurveEdit.gd +++ b/src/UI/Nodes/CurveEditor/CurveEdit.gd @@ -154,6 +154,12 @@ static func to_texture(from_curve: Curve, width := 256) -> CurveTexture: return texture +func set_default_curve() -> void: + if not is_instance_valid(curve): + curve = Curve.new() + _on_presets_item_selected(0) + + func available_size() -> Vector2: if curve_editor.size.is_zero_approx(): return Vector2.ONE diff --git a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd index 7aac6ca81..8e86da5d6 100644 --- a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd +++ b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd @@ -20,6 +20,7 @@ var effects: Array[LayerEffect] = [ "Adjust Brightness/Contrast", preload("res://src/Shaders/Effects/BrightnessContrast.gdshader") ), + LayerEffect.new("Color Curves", preload("res://src/Shaders/Effects/ColorCurves.gdshader")), LayerEffect.new("Palettize", preload("res://src/Shaders/Effects/Palettize.gdshader")), LayerEffect.new("Pixelize", preload("res://src/Shaders/Effects/Pixelize.gdshader")), LayerEffect.new("Posterize", preload("res://src/Shaders/Effects/Posterize.gdshader")),