I do have a completely modular approach for GMAI, that I hope to open source once I get the time. It’s more rather optimised with post-processing filters in mind, but it looks somewhat like this:
local pipeline = require "main.render.pipeline"
local dispatcher = require "crit.dispatcher"
local save_file = require "lib.save_file"
local h_filter_set_enabled = hash("filter_set_enabled")
local h_config_change = hash("config_change")
go.property("enabled", true)
go.property("hook", hash("gui"))
go.property("alpha", true)
local function update_enabled(self)
pipeline.set_module_enabled(self.module, self.enabled and not save_file.config.reduce_vfx)
end
function init(self)
self.module = pipeline.register_module(self.hook, {
sort_order = 10,
output = 1,
render_passes_before = {{
output = pipeline.INPUT,
clear = true,
clear_color = vmath.vector4(0),
}},
render_passes = {{
inputs = {pipeline.INPUT},
output = 1,
settings = self.alpha and "filter_alpha" or "filter",
predicate = "chromatic_abberation",
-- Optimise away clears done to pipeline.OUTPUT
-- since all the pixels will be overwritten anyway
is_clear_invariant = not self.alpha,
}},
})
self.sub_id = dispatcher.subscribe({ h_config_change })
update_enabled(self)
end
function on_message(self, message_id, message)
if message_id == h_filter_set_enabled then
self.enabled = message.enabled
update_enabled(self)
elseif message_id == h_config_change then
if message.key == "reduce_vfx" then
update_enabled(self)
end
end
end
function final(self)
pipeline.unregister_module(self.module)
dispatcher.unsubscribe(self.sub_id)
end