Fragment shader for the entire view area

Is it possible to apply shader to the entire camera view area rather than to a particular model? For simplicity, assume the following program:

#version 130
 
void main() {
  gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}

It should fill the camera view with black color, but in reality only parts where geometry exists are filled, and the rest is filled with clear color (gray by default).

To give some context why would I need that. I want to render a scene to texture, pass that texture to the fragment shader, apply some image filtering algorithm, and finally render the result.

I think that you can do this via rendering Panda’s “render-to-texture” features. See here:
https://www.panda3d.org/manual/?title=Render-to-Texture_and_Image_Postprocessing

[edit] To elaborate a little, the basic idea, I believe, is that you render your scene to a texture, then put that texture onto a full-screen quad and apply your shader to that. Panda provides facilities that enable this, as described in more detail in the manual pages starting from the one to which I linked above.

2 Likes

I know this already is answered, but I wanted to link this gem here, just as a further good resource for such trickery in Panda3D:

2 Likes

Thank you, I appreciate your addition!

1 Like