/*
* Copyright (C) 2012 CyberAgent
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage;
public class GPUImageWeakPixelInclusionFilter extends GPUImage3x3TextureSamplingFilter {
public static final String WEAKPIXEL_FRAGMENT_SHADER = "" +
"precision lowp float;\n" +
"\n" +
"varying vec2 textureCoordinate;\n" +
"varying vec2 leftTextureCoordinate;\n" +
"varying vec2 rightTextureCoordinate;\n" +
"\n" +
"varying vec2 topTextureCoordinate;\n" +
"varying vec2 topLeftTextureCoordinate;\n" +
"varying vec2 topRightTextureCoordinate;\n" +
"\n" +
"varying vec2 bottomTextureCoordinate;\n" +
"varying vec2 bottomLeftTextureCoordinate;\n" +
"varying vec2 bottomRightTextureCoordinate;\n" +
"\n" +
"uniform sampler2D inputImageTexture;\n" +
"\n" +
"void main()\n" +
"{\n" +
"float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n" +
"float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n" +
"float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n" +
"float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n" +
"float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n" +
"float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n" +
"float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n" +
"float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n" +
"float centerIntensity = texture2D(inputImageTexture, textureCoordinate).r;\n" +
"\n" +
"float pixelIntensitySum = bottomLeftIntensity + topRightIntensity + topLeftIntensity + bottomRightIntensity + leftIntensity + rightIntensity + bottomIntensity + topIntensity + centerIntensity;\n" +
"float sumTest = step(1.5, pixelIntensitySum);\n" +
"float pixelTest = step(0.01, centerIntensity);\n" +
"\n" +
"gl_FragColor = vec4(vec3(sumTest * pixelTest), 1.0);\n" +
"}\n";
public GPUImageWeakPixelInclusionFilter() {
super(WEAKPIXEL_FRAGMENT_SHADER);
}
}