This two are My VertexShader and Fragment Shader file:
Vertex Shader File:
attribute vec4 position;
attribute vec4 inputTextureCoordinate;
varying vec2 textureCoordinate;
varying vec4 co;
void main()
{
gl_Position = position;
textureCoordinate = inputTextureCoordinate.xy;
co = inputTextureCoordinate;
}
Fragment Shader File:
uniform sampler2D videoFrame; // the texture with the scene you want to blur
varying mediump vec2 textureCoordinate;
varying mediump vec4 co;
precision mediump float;
vec4 nightVision()
{
float luminanceThreshold = 0.2; // 0.2
float colorAmplification = 2.0; // 4.0
float effectCoverage = 1.0; // 1.0
vec4 finalColor;
// Set effectCoverage to 1.0 for normal use.
if (co.x < effectCoverage)
{
vec3 c = texture2D(videoFrame, co.st).rgb;
float lum = dot(vec3(0.30, 0.59, 0.11), c);
if (lum < luminanceThreshold) {
c *= colorAmplification;
}
vec3 visionColor = vec3(0.1, 0.95, 0.2);
finalColor.rgb = (c) * visionColor;
} else {
finalColor = texture2D(videoFrame, co.st);
}
vec4 sum = vec4(0.0, 0.0, 0.0, 1.0);
sum.rgb = finalColor.rgb;
return sum;
}
void main(void)
{
gl_FragColor = nightVision();
}
Now, I want to Use this code to give the Camera Preview Effect in Android Camera preview. And also want to save the Picture that captured by that effect.
So is it possible to do so ??? If yes then Please help me with Some code as i am new to OpenGles with Android Camera.