UPBGE / upbge

UPBGE, the best integrated game engine in Blender
https://upbge.org
Other
1.39k stars 177 forks source link

add GetColorTexture and GetDepthTexture to KX_FilterFrameBuffer #1875

Closed IzaZed closed 4 months ago

IzaZed commented 4 months ago

This feature allows KX_FilterFrameBuffer to provide a GPUTexture object when added as offscreen buffer. This texture can then be used in other shaders and the gpu module draw calls.

Usage:

filter = bge.logic.getCurrentScene().filterManager.addFilter(0, 12, glsl)
filter.addOffScreen(0)

and then to get the texture (and use it as uniform sampler custom_framebuffer in glsl):

texture_object = filter.offScreen.getColorTexture()
shader = GPUShader(...., ....)
shader.uniform_sampler('custom_framebuffer', texture_object)

Test File: Test04.zip

youle31 commented 4 months ago

Hello, it sounds good, I didn't test your patch but i tested on my side and it was approximatively the same. There is just the doc missing; You can add few lines in bge.types.KX_2DFilterFrameBuffer.rst taking care about indentation/whitespaces and merge. Thanks!!