FBO question

来源:互联网 发布:ios2k16库里捏脸数据 编辑:程序博客网 时间:2024/05/20 06:57

导读:
  







 FBO question





  











hello everyone. a question regarding FBOs. just started playing around with it.

i'm using fbo and drawing to two different textures using GLSL. multiple rendering target was it called?(gl_FragColor[0] and [1] method). everything works fine up to here. but now i want to do some processing on second texture and then blend them together, but.. how?

i don't know where to begin.

do i just create a quad shaped polygon and draw the textures and blend two textures on the quad? so entire game i'll be looking at this quad and fbo is changing texture constantly? is that how it works? it did sort of work this way but i'm not sure this is the correct way of doing it. and seems really slow too. argh

rendering to texture i understand, but i don't know how to display it on to screen.

really would appreciate help on this :(

thank you







 User Rating: 1000   |  Rate This User Report this Post to a Moderator | Link















Full screen quad is the way to go. You can display a render texture to the screen by binding this texture and drawing a full screen quad into the framebuffer. If it seems slow, there are a few methods to speed it up.

First is to move blending from the pixel shader to the ROP. How are you doing blending, in the shader or by using fixed-function blending (glBlendFunc)? Moving operations to the ROP might help because it distributes work across different units (ROP works in parallel with the shader unit).

Second is to use alpha testing whenever possible, for example if for certain areas post processing doesn't change the pixel color.

Third is to minimize the number of passes. Say, your post processing works like this:

draw to texture A
draw to texture B
blend A and B into texture C
draw C into framebuffer (to display)

You can improve it by eliminating extra passes:

draw to texture A
draw to texture B
blend A and B into framebuffer

or how about:

draw to texture A
draw to framebuffer and blend whatever you draw into texture B with texture A




deathkrush
PS3/Xbox360 Graphics Programmer, THQ.
Completed Projects: Stuntman Ignition (PS3)








 User Rating: 1121   |  Rate This User Report this Post to a Moderator | Link















oh thank you for replying! :D

ok. so.. what i'm doing is sort of correct. using the quad to draw the textures. hmm...

ROP.. sounds.. interesting. never used it before. i'm going to have to check it out.

i think i'm currently using the second method from the three. blending A and B to quad in fragment shader, instead of creating texture C.

could you explain how "draw to framebuffer and blend whatever you draw into texture B with texture A" works please? i couldn't understand that part. :(

thank you!!







 User Rating: 1000   |  Rate This User Report this Post to a Moderator | Link
















Quote:



Original post by w0nd

could you explain how "draw to framebuffer and blend whatever you draw into texture B with texture A" works please? i couldn't understand that part. :(



I dunno what I was thinking on that one :-) But the basic idea is to get rid of redundant passes and to combine them into a single draw call. So, if it makes sense, "draw to texture B + blend A and B into framebuffer" can be combined into a single draw call by drawing into framebuffer directly and skipping "draw to texture B step".

BTW, ROP stands for Raster OPerations unit.




deathkrush
PS3/Xbox360 Graphics Programmer, THQ.
Completed Projects: Stuntman Ignition (PS3)








 User Rating: 1121   |  Rate This User Report this Post to a Moderator | Link















ah... ok. i understand now :D

thanks for the help deathkrush! now i know where to start.

thanks again!






 User Rating: 1000   |  Rate This User 


本文转自
http://www.gamedev.net/community/forums/topic.asp?topic_id=462653