Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update File RGB #51

Merged
merged 1 commit into from
May 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions epf/src/main/java/com/daasuu/epf/filter/GlRGBFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ public class GlRGBFilter extends GlFilter {
" uniform highp float red;\n" +
" uniform highp float green;\n" +
" uniform highp float blue;\n" +
" uniform lowp float brightness;\n" +
" uniform lowp float saturation;\n" +
" uniform lowp float contrast;\n" +
" \n" +
" const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n" +
" \n" +
" void main()\n" +
" {\n" +
" highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
" lowp vec4 textureOtherColor = texture2D(sTexture, vTextureCoord);\n" +
" lowp float luminance = dot(textureOtherColor.rgb, luminanceWeighting);\n" +
" lowp vec3 greyScaleColor = vec3(luminance);\n" +
" \n" +
" gl_FragColor = vec4(textureColor.r * red, textureColor.g * green, textureColor.b * blue, 1.0);\n" +
" gl_FragColor = vec4((textureOtherColor.rgb + vec3(brightness)), textureOtherColor.w);\n" +
" gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureOtherColor.w);\n" +
" gl_FragColor = vec4(((textureOtherColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureOtherColor.w);\n" +
" }\n";

public GlRGBFilter() {
Expand All @@ -33,6 +44,9 @@ public GlRGBFilter() {
private float red = 1f;
private float green = 1f;
private float blue = 1f;
private float brightness = 0f;
private float saturation = 1f;
private float contrast = 1.2f;

public void setRed(float red) {
this.red = red;
Expand All @@ -46,10 +60,25 @@ public void setBlue(float blue) {
this.blue = blue;
}

public void setBrightness(float brightness) {
this.brightness = brightness;
}

public void setSaturation(float saturation) {
this.saturation = saturation;
}

public void setContrast(float contrast) {
this.contrast = contrast;
}

@Override
public void onDraw() {
GLES20.glUniform1f(getHandle("red"), red);
GLES20.glUniform1f(getHandle("green"), green);
GLES20.glUniform1f(getHandle("blue"), blue);
GLES20.glUniform1f(getHandle("brightness"), brightness);
GLES20.glUniform1f(getHandle("saturation"), saturation);
GLES20.glUniform1f(getHandle("contrast"), contrast);
}
}