I have next two shaders: vertex shader:
/// fragment shader
#version 130
in vec2 vs_uv;
out vec4 fs_color;
uniform sampler2D u_source;
uniform sampler2D u_map;
void main() {
fs_color = vec4(vs_uv, 0, 1);
}
/// vertex shader
#version 130
out vec2 vs_uv;
void main() {
const vec4 vertices[4] = {
vec4(-1, -1, 0, 1),
vec4(-1, 1, 0, 0),
vec4(1, 1, 1, 0),
vec4(1, -1, 1, 1)
};
vec4 description = vertices[gl_VertexID];
gl_Position = vec4(description.xy, 0, 1);
vs_uv = description.zw;
}
Obviously, it renders a full-screen gradient-filled rectangle. I created a program with this two shaders and rendered 4 vertices into framebuffer and return rendered color texture from it:
public Texture apply(Texture source, Texture map) {
m_renderBuffer.begin();
Gdx.gl20.glClear(Gdx.gl20.GL_COLOR_BUFFER_BIT);
m_program.begin();
m_program.setUniformi(m_sourceLocation, 0);
m_program.setUniformi(m_mapLocation, 1);
Gdx.gl20.glDrawArrays(Gdx.gl20.GL_TRIANGLE_FAN, 0, 4);
m_program.end();
m_renderBuffer.end();
return m_renderBuffer.getColorBufferTexture();
}
I draw rendered texture with a SpriteBatch:
m_lightSpriteBatch.begin();
m_lightSpriteBatch.draw(lightTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
m_lightSpriteBatch.end();
It works well and renders gradient-filled rectangle as I want. When I bind two textures (passed as parameters for apply method - source and map) after meginning of the program:
m_program.begin();
source.bind(0);
map.bind(1);
...
It renders crap even considering what I use no textures in the shader's code!

- texture rendered with no texture bindings
sourcetexture- "crappy" rendered texture
maptexture
apply. It provides sprites for 2nd image. It's not a bunch of textures, it's one texture. - Deedee Megadoodoo