如何在kivy中进行多个fbo工作?

时间:2017-12-11 12:34:18

标签: python kivy kivy-language

我正在使用kivy处理3D。我想通过后处理着色器制作绽放效果。我不知道如何在kivy中传递多个fbo ..我可以进行一次传递但是不能进行多次传递。所以,任何人都可以帮助我吗?

这是我的代码:

class SergioGameEngine(Widget):
    def __init__(self, **kwargs):

    self.canvas = RenderContext(size = self.size,clear_color=(0.5,0.5,0.5,1.0))


    with self.canvas:

        self.viewport = Rectangle(size=(self.size), pos=self.pos)
        self.fbo = Fbo(size=self.size,
                            with_depthbuffer=True,
                            compute_normal_mat=True,
                            clear_color=(0.5, 0.5, 0.5, 1.))
    self.fbo.shader.source = resource_find('simple.glsl')
    Loading meshes.....

    with self.fbo:
        self.cb = Callback(self.setup_gl_context)
        PushMatrix()



        self.setup_scene()
        PopMatrix()
        self.cb = Callback(self.reset_gl_context)


   self.canvas.shader.fs = fsi #this is postprocessing shader
   self.pm = Window.render_context['projection_mat']
   self.mm = Window.render_context['modelview_mat']
   self.canvas['projection_mat'] = self.pm
   self.canvas['modelview_mat'] = self.mm

def on_pos(self, instance, value):
    self.viewport.pos = (0.0,0.0)
    print(value)

def on_texture(self, instance, value):
    self.viewport.texture = self.fbo.texture


fsi = """postprocessing shader"""

现在,使用fbo纹理更新画布视口... 视口纹理用作画布片段着色器上的采样器,我可以编辑该屏幕纹理...但问题是我如何将画布输出的frametexture再次作为采样器再次传递给屏幕着色器?

:)

0 个答案:

没有答案