FrankMonza
FrankMonza

Reputation: 2044

How to apply a mask filter to current framebuffer in OpenGL ES 2

Let's say i have a 2D game full of sprites, i draw my sprites with a very simple shader like:

precision mediump float;
uniform sampler2D uTexture;
varying vec2 vTexPos;
void main() {
  gl_FragColor = texture2D(uTexture, vTexPos);
}

Then, at a certain point, i want to render an area of my current scene in grayscale to apply then some text on top (see example below), so, let's say that i have a vector with the mask, how the shader will look like? how do i access in Android OpenGL 2 current framebuffer to filter it?

current scene expected result

Upvotes: 1

Views: 1187

Answers (1)

sravan
sravan

Reputation: 138

how do i access in Android OpenGL 2 current framebuffer to filter it?

here is a link to blogpost, which explains about settingup framebuffer and render to frame buffer http://opengles2learning.blogspot.in/2014/02/render-to-texture-rtt.html

once you render your scene to texture, you can apply filters.

Upvotes: 2

Related Questions