1

I have a texture and i would like to apply to it a glsl shader. Is it possible and how to do it ? For example i want to apply this glsl shader to my texture :

varying vec4 coord;

uniform sampler2D texture;
uniform float opacity;

void main() {
  vec4 col = texture2D(texture, coord.xy);
  col.a *= opacity;

    gl_FragColor = col;

}
zeus
  • 12,173
  • 9
  • 63
  • 184
  • 2
    I also think this question is too board (and close-voted accordingly.) The short answer is: render a full-screen quad (or even better: a full-screen triangle) while applying this as the fragment shader. The vertex shader can be quite trivial. – derhass Jun 30 '18 at 17:24

1 Answers1

1

I would say create another texture empty and of similar properties of original texture. Attach this texture to fbo and send fbo and original texture in shader. Generate full quad pass of you size of texture. Read texel from original texture in shader apply your code from fragment shader and write value to fbo attached texture using gl_FragCoord. And tge attached texture is result you want.