From 80e93629d185e86942eccc9a263c5d26774ad9cc Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:36:01 +0200 Subject: [PATCH] Add PXO_frame and PXO_layer as special loaded shader uniforms --- src/Classes/Layers/BaseLayer.gd | 2 ++ src/Classes/ShaderLoader.gd | 2 +- src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Classes/Layers/BaseLayer.gd b/src/Classes/Layers/BaseLayer.gd index 9bb2de7b4..b4577c4b7 100644 --- a/src/Classes/Layers/BaseLayer.gd +++ b/src/Classes/Layers/BaseLayer.gd @@ -236,6 +236,8 @@ func display_effects(cel: BaseCel, image_override: Image = null) -> Image: continue var params := effect.params params["PXO_time"] = cel.get_frame(project).position_in_seconds(project) + params["PXO_frame"] = project.frames.find(cel.get_frame(project)) + params["PXO_layer"] = index var shader_image_effect := ShaderImageEffect.new() shader_image_effect.generate_image(image, effect.shader, params, image_size) # Inherit effects from the parents, if their blend mode is set to pass through diff --git a/src/Classes/ShaderLoader.gd b/src/Classes/ShaderLoader.gd index 63fa59bd6..97f706dad 100644 --- a/src/Classes/ShaderLoader.gd +++ b/src/Classes/ShaderLoader.gd @@ -63,7 +63,7 @@ static func create_ui_for_shader_uniforms( var u_init := u_left_side[0].split(" ") var u_type := u_init[1] var u_name := u_init[2] - if u_name == "PXO_time": + if u_name in ["PXO_time", "PXO_frame", "PXO_layer"]: continue # Find custom data of the uniform, if any exists # Right now it only checks if a uniform should have another type of node diff --git a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd index caadd3b5b..114acaf1e 100644 --- a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd +++ b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd @@ -168,7 +168,8 @@ func _apply_effect(layer: BaseLayer, effect: LayerEffect) -> void: var index := layer.effects.find(effect) var redo_data := {} var undo_data := {} - for frame in project.frames: + for i in project.frames.size(): + var frame := project.frames[i] var cel := frame.cels[layer.index] var cel_image := cel.get_image() if cel is CelTileMap: @@ -179,6 +180,8 @@ func _apply_effect(layer: BaseLayer, effect: LayerEffect) -> void: var image_size := cel_image.get_size() var params := effect.params params["PXO_time"] = frame.position_in_seconds(project) + params["PXO_frame"] = i + params["PXO_layer"] = layer.index var shader_image_effect := ShaderImageEffect.new() shader_image_effect.generate_image(cel_image, effect.shader, params, image_size)