Shaders and Backbuffer

Started by
9 comments, last by Pipo DeClown 19 years, 7 months ago
Hola to everyone, just for knowledge, is there a way to access within the pixel shaders the backbuffer as if it was a simple texture so that i can test some image post-processes, or a way to do something similar(without render the scene in a texture or blitting da bb into it :)? Thanx in advance to all !!! [Edited by - giuseppeCT on September 14, 2004 6:16:31 AM]
Advertisement
Don't think so. I'm pretty confident that the best way is to render your scene to a texture, and then read from that texture in the pixel shader.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Sure, looking to the 3d render pipeline there are not chances to do that other than draw to a render target texture, it were obvious, anyway pretty wasteful !!! thanx for the answer dude !!
You may render to the backbuffer and then copy that surface to your own texture and use that texture as a source for the pixel shader. (IDirect3DDevice9::GetBackBuffer and IDirect3DDevice9::UpdateSurface) This is also a waste of time but at least antialiasing will work. (AFAIK if you are rendering to a rendertarget AA will be disabled)
I may be completly offbase and I don;t know what you are trying to accomplish but if alphablending where enabled you could simply never clear the backbuffer and do things in a multipass way.
Quote:Original post by imajor
(AFAIK if you are rendering to a rendertarget AA will be disabled)

This is true for Directx 8 not 9.Directx 9 support AA when rendering to a render target.
Reading the backBuffer is very slow and stops the parallelism between the CPU and the GPU unless you use the D3DLOCK_DONOTWAIT Flag (Sorry if the spelling is wrong). Generally locking the back buffer is something that Causes the driver to flush the pipeline, and I think it is not good to lock the whole back buffer. this will cause the back buffer to be copied to the memory which depends on your bus speed.
So, how's made the fullscreen filter effect in prince of persia ? i remeber one of my friends had a bug in its video card driver where it was very evident, a kind of filter upon all the screen but wrong aligned.....
Render to texture, then draw a quad to the backbuffer with one texture being your rendertarget containing the scene and another the effect to overlay. Or whatever - depends on the effect.
The effect would probably be a result of some function on your scene rendertarget.
As supposed, anyway i remember that create textures with size other than power x with base 2 does'nt works with all videocards, so i think i could create a texture of size power x with base 2 and play with texcoords......right?

This topic is closed to new replies.

Advertisement