Still on the post processing topic from last week, i came back to try it once again. After lots of testing i found this:
The game first renders the whole game world into a rt (render target) game_world_fbo
. Then enables it as a texture for tex0
:
render.disable_render_target(self.game_world_fbo)
render.enable_texture(0, self.game_world_fbo, render.BUFFER_COLOR0_BIT)
then, the render script uses this texture in a draw call to the post process quad, that process quad has a material that only outputs the brightest pixels of it. This material uses the tex0
enabled before, that means the image is just the game world and it extracts the brightest pixels of it. Debugging it on render doc, this is the output after all this:
regular game world before and after the brightness filter:
all a ok until here.
Note that the brightness filter is done on a render target called just bright
, which is then disabled and transformed in a texture for tex0
:
render.enable_render_target(self.bright)
render.set_render_target(self.bright)
-- changes the material to filterring brightest pixels
render.enable_material('bright')
render.draw(self.post_processing_pred)
Acording to renderdoc, the texture is fine in the output:
(in the above image, the first call to
glDrawElements
is the defold model which has lighting applied to it, the second one is the quad, the quad itself is only 2 tris)
After this step in the render script, it is time to blur the image. It disables the bright
rt, turns it into an image for use in tex0
. Then I change the enabled material to the blurring one and just draw the same quad in a different target:
render.disable_render_target(self.bright)
render.enable_texture(0, self.bright, render.BUFFER_COLOR0_BIT)
render.enable_render_target(self.blur_fbo[hor])
render.set_render_target(self.blur_fbo[hor])
local constants = render.constant_buffer()
constants.BLUR_viewPort_Radius = vmath.vector4(add_blur, 0,0, not_hor)
render.draw(self.post_processing_pred, {constants = constants})
it then gives me a pitch black screen, only the gui is rendered succesfully as seen by the frame counter:
The odd thing to note is that the renderdoc says that the last step, the blurring, dont have to get any image input, that means, nothing is on tex0
:
the code is currently on this repo, i just pick the most important parts for the problem, but idk if the problem is actually only in those parts i talked about: https://github.com/Caue-Aron/Defold-Post-Processing-Test/tree/optmized-blur
Any help is greatly appreciated!