Skip to main content
gamedev.net
🔒 Locked

Multiple FBO's

Started by Ishilra Jan 29, 2009 at 3:33 AM 2 replies 850+ views
Original Post
Ishilra
Ishilra
I have some problems with iteratively writing into the fbo. What I need to do is written below in a pseudocode..

foreach randomly moving sphere
{
   ClearColor for FBO1();
   Render To FBO1(); // stored in currentFBO
   Send CurrentFBO texture to shader for operations;
   // Here I don't clear color for iteratively blending
   Render The Resulting Texture to FBO2(); // stored in backgroundFBO
}

// Final Step
Draw Quad Using backgroundFBO's texture..


In the shader, I sample the texture for motion blur. The blurred image is successfully stored in backgroundFBO; however, in the final step, I only see the last sphere's blurred image. I was expecting to see all blurred spheres since I don't clear backgroundFBO. I'm not sure why this isn't working as glCopyTexImage. What do I need to do in order to solve this situation? Hoping that I mentioned the problem clearly. Thanks for the help.
Thaligar
Thaligar
Actually this is only a guess,

the texture which you generate has alpha all set to 1.0 or (transparent things should have 0.0)?
you do also no alpha blending at all on your textures to merge them or?

Looks like a pure overwrite when you copy fbo1 to fbo2.

the background isn't automatically removed from your textures in the moment were you copy fbo1 to the fbo2. you have to blend them to get proper results. Otherwise you overwrite the color information of fbo2 with the one from fbo1, which seems to happen.

try to do alpha blending on the textures and say if this solves your problem.

greets,
tgar
Ishilra
Ishilra
Actually that worked :) I just decreased w value in the pixel shader from 1.0 to 0.5 and now I can see all. However, I cannot see them at full brightness (as expected). So I multiplied the color by some constant. Is there any better way to restore the color in the gpu? Or multiplying is good enough :)
Thanks for the help!
Thaligar
Thaligar
Ok,

1.) when you clear the fbo1 texture, set alpha to 0.0.
(Now the whole texture is transparent)

2.) in the shader were you draw the sphere render the sphere with alpha 1.0 (this sets the sphere in the texture to be fully opaque)

3.) now render the motion blur with some alpha value between 0.1 and 0.9 in the shader (some more or less transparent value)

finally if you merge fbo1 to fbo2 (if this works as expected) the background should not overwrite anything previously generated (because it's fully transparent) the sphere will overwrite everything beneath it (fully opaque) and the motion blur will be softly merged with the whole scene.

try and come back ;)

greets,
tgar

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.