Thank you, seems to work for me. Here a test where I just desaturate a game:
I used the shaders as following.
Vertex:
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 textureMatrix;
uniform vec4 additionalColor;
uniform vec4 ambientColor;
uniform float alpha;
uniform bool useColors;
attribute vec4 position;
attribute vec4 color;
attribute vec2 texture0;
varying vec2 texCoord;
varying vec4 vertexColor;
void main() {
texCoord = (textureMatrix * vec4(texture0, 0, 1)).xy;
vec4 vertexPos = modelViewMatrix * position;
vertexColor = ambientColor + additionalColor;
vertexColor=vec4(min(vec3(1), vertexColor.xyz * color.xyz), alpha);
gl_Position = modelViewProjectionMatrix * position;
}
Fragment:
precision mediump float;
uniform sampler2D textureUnit0;
varying vec2 texCoord;
varying vec4 vertexColor;
void main() {
vec4 col = texture2D(textureUnit0, texCoord) * vertexColor;
float grey = 0.3 * col.r + 0.6 * col.g + 0.1 * col.b;
col = vec4(vec3(grey), col.a);
gl_FragColor=col;
}
Which shader code is used for blitting by default? Maybe you can also provide it's source if it contains some useful optimizations.
Z-Testing in this context means that one can set a depth value for each blit and only fragments with smaller depth value should be drawn. I could need this to solve some issues with drawing the cars. I always have to draw them in the right order now to avoid wrong overlapping.