diff --git a/src/Classes/Cels/BaseCel.gd b/src/Classes/Cels/BaseCel.gd index 4b01ec7d8..e2786034b 100644 --- a/src/Classes/Cels/BaseCel.gd +++ b/src/Classes/Cels/BaseCel.gd @@ -24,6 +24,13 @@ func get_final_opacity(layer: BaseLayer) -> float: return layer.opacity * opacity +func get_frame(project: Project) -> Frame: + for frame in project.frames: + if frame.cels.has(self): + return frame + return null + + # Methods to Override: diff --git a/src/Classes/Layers/BaseLayer.gd b/src/Classes/Layers/BaseLayer.gd index a63e4e8dd..9bb2de7b4 100644 --- a/src/Classes/Layers/BaseLayer.gd +++ b/src/Classes/Layers/BaseLayer.gd @@ -234,8 +234,10 @@ func display_effects(cel: BaseCel, image_override: Image = null) -> Image: for effect in effects: if not effect.enabled or not is_instance_valid(effect.shader): continue + var params := effect.params + params["PXO_time"] = cel.get_frame(project).position_in_seconds(project) var shader_image_effect := ShaderImageEffect.new() - shader_image_effect.generate_image(image, effect.shader, effect.params, image_size) + 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 for ancestor in get_ancestors(): if ancestor.blend_mode != BlendModes.PASS_THROUGH: diff --git a/src/Classes/ShaderLoader.gd b/src/Classes/ShaderLoader.gd index a154ccfe8..31a8487b9 100644 --- a/src/Classes/ShaderLoader.gd +++ b/src/Classes/ShaderLoader.gd @@ -62,6 +62,8 @@ 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": + continue # Find custom data of the uniform, if any exists # Right now it only checks if a uniform should have another type of node # Such as integers having OptionButtons diff --git a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd index 6979cb998..caadd3b5b 100644 --- a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd +++ b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd @@ -177,8 +177,10 @@ func _apply_effect(layer: BaseLayer, effect: LayerEffect) -> void: undo_data[cel_image.indices_image] = cel_image.indices_image.data undo_data[cel_image] = cel_image.data var image_size := cel_image.get_size() + var params := effect.params + params["PXO_time"] = frame.position_in_seconds(project) var shader_image_effect := ShaderImageEffect.new() - shader_image_effect.generate_image(cel_image, effect.shader, effect.params, image_size) + shader_image_effect.generate_image(cel_image, effect.shader, params, image_size) var tile_editing_mode := TileSetPanel.tile_editing_mode if tile_editing_mode == TileSetPanel.TileEditingMode.MANUAL: