A question on fragment shaders, and PBuffers
Two questions, I'd make two posts but they're related.
First, can a fragment shader read what's in the color buffer for the purpose of blending?
E.g., say I draw a quad across the screen and have a shader bound to that quad. Can I, for each pixel being written, read in whatever's in the destination color buffer and use that to affect how the result is written? Specifically, I'm writing a "death effect" and would like to drop the scene to grayscale before blending a color against it.
If this isn't possible, if I recall there was a problem with full-screen PBuffers. Is this still the case? Was it ever the case? I know that if the above isn't possible I can simply render my scene into a texture and let my shader run against that.
Thanks,
First, can a fragment shader read what's in the color buffer for the purpose of blending?
E.g., say I draw a quad across the screen and have a shader bound to that quad. Can I, for each pixel being written, read in whatever's in the destination color buffer and use that to affect how the result is written? Specifically, I'm writing a "death effect" and would like to drop the scene to grayscale before blending a color against it.
If this isn't possible, if I recall there was a problem with full-screen PBuffers. Is this still the case? Was it ever the case? I know that if the above isn't possible I can simply render my scene into a texture and let my shader run against that.
Thanks,
a) no, you can't read any buffers from a fragment shader. blending happens as usual after the fragment shader has done its thing.
depending on what you're trying to do, you may be able to render the entire scene into a PBuffer, then draw the main view as a full-screen quad, which you can pixel shade to your heart's content.
b) No, there was never a problem with full-screen PBuffers AFAIK.
depending on what you're trying to do, you may be able to render the entire scene into a PBuffer, then draw the main view as a full-screen quad, which you can pixel shade to your heart's content.
b) No, there was never a problem with full-screen PBuffers AFAIK.
Too bad about the former, but given that there's no trouble with fullscreen PBuffers, I'll run thataway. Beats me where I got the idea that there was a problem...
Anyway, I'll give it a shot. Thanks OSC.
Anyway, I'll give it a shot. Thanks OSC.
I got it working this weekend. Thanks for the tip, OSC.
One thing, in case anybody else tries this stuff, none of my resources covered how to use the TEX shader command when you're dealing with non-POT textures. The books I've got mention "1D", "2D", "3D", "CUBE", but that's it.
I don't have internet access at home, so I just sort of figured it out, but, I passed "RECT" instead of "2D" when looking up texture data from the pbuffer texture and it worked.
One thing, in case anybody else tries this stuff, none of my resources covered how to use the TEX shader command when you're dealing with non-POT textures. The books I've got mention "1D", "2D", "3D", "CUBE", but that's it.
I don't have internet access at home, so I just sort of figured it out, but, I passed "RECT" instead of "2D" when looking up texture data from the pbuffer texture and it worked.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| passing values from vertex to fragment shader | Sumaleth | 6 | 8,641 |
Feb 18, 2011 01:54 AM Last Post: Holmes |
|
| GLSL geometry- and multipass-shaders (nogo?) | mcMike | 3 | 5,070 |
May 2, 2008 05:51 AM Last Post: mcMike |
|
| GLSL fragment program limits on GMA950 (MacBook) | memon | 12 | 7,953 |
Oct 26, 2007 05:18 PM Last Post: arekkusu |
|
| PBuffers and setTextureImageToPBuffer:colorBuffer: | Marjock | 4 | 2,413 |
Jul 16, 2006 01:19 AM Last Post: Marjock |
|
| Enabling OGL fog in shaders | kordova | 7 | 4,372 |
Jul 12, 2006 10:12 AM Last Post: kordova |
|

