Results 1 to 2 of 2

Thread: Render to / and use texture

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1

    Render to / and use texture

    Hi,

    I'm trying to create a cummulative effect in which new data is added to the framebuffer on each frame.
    Ideally I would like to render the first frame to a texture and then use this texture as the background for the next, add the 2nd frame to it and so on...

    Doe anybody know if this is possible using (only) vertex/fragment shaders in WebGL? I guess I can probably read back the texture and download it again, but I expect to have some performance issues doing this.

    Thx !

  2. #2
    Senior Member
    Join Date
    May 2010
    Posts
    207

    Re: Render to / and use texture

    Ideally, you want to render to an FBO so you can read that into a texture on the following frame. However, because you're not allowed to read and write from the same texture at the same time, you will need to do a double-buffer arrangement. So create two texture/FBO's (let's call them A & B).

    Bind A as a texture, set B as the render target.
    Draw your new effect into B, merging in A as you go.
    Bind B as a texture, copy it onto the screen by drawing a screen-sized quad.
    Swap A and B.
    Repeat.

    You can do that pretty fast.

Similar Threads

  1. Render to texture
    By debinair in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 1
    Last Post: 04-23-2012, 05:26 AM
  2. Render to texture
    By miketyson27 in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 05-18-2009, 01:58 AM
  3. render to texture
    By cobrahc in forum OpenGL ES general technical discussions
    Replies: 4
    Last Post: 06-30-2008, 09:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •