Back to project page FxCameraApp.
The source code is released under:
MIT License
If you think the Android project FxCameraApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.af.experiments.FxCameraApp.shaders; /*from ww w .j a v a 2 s . c om*/ import static android.opengl.GLES20.glUniform1f; public class GlPosterizeShader extends GlShader { private static final String FRAGMENT_SHADER = "precision mediump float;" + // ????????????????? "varying vec2 vTextureCoord;" + "uniform lowp sampler2D sTexture;" + "uniform highp float colorLevel;" + "void main() {" + "highp vec4 color = texture2D(sTexture, vTextureCoord);" + "gl_FragColor = floor((color * colorLevel) + vec4(0.5)) / colorLevel;" + "}"; private float mColorLevel = 5f; protected String mShaderName = "Posterize"; public String getName() { return mShaderName; } public GlPosterizeShader() { super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER); } public float getColorLevel() { return mColorLevel; } public void setColorLevel(final float colorLevel) { mColorLevel = colorLevel; } ////////////////////////////////////////////////////////////////////////// @Override public void onDraw() { glUniform1f(getHandle("colorLevel"), mColorLevel); } }