Problem to write fragment buffer

Hi,

I would like to write the output/buffer of fragment shader as I wish (e.g. all white), however this result is depending of the model’s shapes presented in the scene. How can I proceed with this correctly?

Follow below my minimal source code and the results.

Thanks in advance!

  • Vertex:
#version 130

void main() {
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
  • Fragment:
#version 130

void main() {
    gl_FragData[0] = vec4(1,0,0,1);
}
  • Expected result:
    [ATTACH=CONFIG]1825[/ATTACH]

  • Current result:
    [ATTACH=CONFIG]1826[/ATTACH]

[QUOTE=romulogcerqueira;1292257]I would like to write the output/buffer of fragment shader as I wish (e.g. all white),
however this result is depending of the model’s shapes presented in the scene.[/quote]

In order to write a value for pixel, the shape(s) you send down have to cover the pixel. If you want to fill the whole screen, send down a full-screen quad.

You also need to turn off any pipeline state (or internal app processing such as post-FX) which could modify the output of your fragment shader before it hits the framebuffer. For example, disable state such as BLENDing, ALPHA_TESTing, and multisample antialiasing.

Hi @DarkPhoton,

thanks for your comment. I am using FBO-RTT in my C++/OSG code, so the gl_FragData is writing the buffer in the correct texture. In this case, is it necessary to send down a full-screen quad?

Could you kindly give an example how can I do this?

Best regards,

Rômulo

In OSG? No. You’re more likely to find what you want looking through the OSG examples, searching the OSG mailing lists or forums, or reading the OSG docs. Basically you want to create an osg::Geometry containing a quad, a StateSet that turns off things like blending, alpha test, etc., and an Camera with a viewing and ortho projection that have the quad filling the width/height of the view frustum and screen.

A random web search for “openscenegraph full-screen quad” turns up this as the first hit:

http://forum.openscenegraph.org/viewtopic.php?t=13319

Search down to createTexturedQuadGeometry. I have no idea if this is the best way to do it in the latest OSG.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.