Hello there,
I’ve been trying to wrap my head around OpenGL for the past few days and have stumbled into some questions regarding the render scripting and render targets.
I have created my render target
self.render_target_shadowmap = render.render_target("shadowmap", parameters)
and this seems to be how you draw onto that render target
render.enable_render_target(self.render_target_shadowmap)
render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color})
render.draw(self.light_pred)
render.disable_render_target(self.render_target_shadowmap)
I then want to draw this shadowmap, blending it on top of my scene. I’ve managed to do this through rendering onto a GUI box-node, covering the screen (and also being rotated 180 degrees around Y, because the output image would otherwise be mirrored) and then setting the box-node’s blend mode to multiply.
render.enable_texture(0, self.render_target_shadowmap, render.BUFFER_COLOR_BIT)
render.draw(self.screenquad_pred)
render.disable_texture(0, self.render_target_shadowmap, render.BUFFER_COLOR_BIT)
Would you say that this is the intended way to do fullscreen draw operations or are there other ways?
What I really would like to do is draw both my scene and the shadowmap to separate render targets and then pass them as textures to the shader where I can do custom blend operations. Is there currently any way of doing that in Defold?
Render scripting seems really nice to use. I’m just hoping for as much flexibility as possible.