I’m trying to make an optimal blur shader, for that im using learnopengl’s method:
https://learnopengl.com/Advanced-Lighting/Bloom
Thing is, this method requires the modification of a single uniform variable in the shaders. The way i aproached that is by sending a message to the go that holds the mesh which has this shader. This turned out to not work, i think its bc its not fast enough (maybe). I do this:
local first_iteration = true
local amount = 10
for i = 1, amount do
render.set_render_target(self.blur_fbo[boolToNumber(horizontal)])
msg.post(blur_go, hash'blur_dir', {horizontal = boolToNumber(horizontal)})
if first_iteration then
render.disable_render_target(self.game_world_fbo)
render.enable_texture(0, self.game_world_fbo, render.BUFFER_COLOR0_BIT)
render.draw(self.post_processing_pred)
first_iteration = false
else
render.enable_texture(0, self.blur_fbo[boolToNumber(not horizontal)], render.BUFFER_COLOR0_BIT)
render.draw(self.post_processing_pred)
render.disable_render_target(self.blur_fbo[boolToNumber(horizontal)])
end
horizontal = not horizontal
render.disable_texture(0)
end
this is the C++ code from learnopengl i translated to lua/defold. Thing is, the result i get with this is either the blur is applied only vertically or horizontally, never in both ways:
The way i would overcome that is with coroutines: i send the message, stop the rendering corroutine, when the go is done continue the corroutine from the go script. IDK how performance wise is that, but its the only thing i can think of, since i cannot call a go.set on rendering script and idk any other way of setting a uniform on the render script. If anyone has any other idea please tell me.