libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
256 stars 81 forks source link

allowing to render inside a FBO #53

Closed alwex closed 7 years ago

alwex commented 9 years ago

currently it is not possible to do something like:

frameBuffer.begin();
rayHandler.render();
frameBuffer.end();

because the rayHandler use it's own FBO. One solution would be to allow to drive FBO outside of the render function or to provide a FBO manager handling a stack of FBOs

see http://stackoverflow.com/questions/25471727/libgdx-nested-framebuffer for a possible solution

rinold commented 9 years ago

What you want to achieve using such FBO wrapping around the rayHandler?

alwex commented 9 years ago

I want to be able to apply some multiple pass processing shaders above the rendered scene for example.

rinold commented 9 years ago

Sorry, I'm unfortunatelly not an exepert regarding the FBOs :) but isn't that currently possible with disabled automatic drawing for lightmap (#setLightMapRendering(false)) and the #getLightMapTexture() or #getLightMapBuffer()?

alwex commented 9 years ago

I have to look into this. Maybe I'll be able to manage the lightMapBuffer out of the library like this

rayHandler.setLightMapRendering(false);
FBOManager.begin(rayHandler.getLightMapBuffer());
rayHandler.render();
FBOManager.end();

(FBOManager just handle a stack of FBO to avoid them drawing on each others.

alwex commented 9 years ago

I have made the test with the FBOManager I told you about (http://stackoverflow.com/questions/25471727/libgdx-nested-framebuffer) and the light can now be rendered inside another FBO. I think that libgdx may come with such an FBOManager to be able to share it within the differents libraries.

The tweek is just to replace all the fbo.begin() stuff by FBOManager.instance.begin(fbo) and the FBOManager will take care of begin/end of all of it's FBO.