Feature: change GLES2.0 to GLES3.0

pull/221/head
xufuji456 2 years ago
parent 3be79a856c
commit 55f034aa5c
  1. 6
      CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautySketchFilter.java
  2. 20
      CameraFilter/src/main/res/raw/default_fragment.glsl

@ -1,7 +1,7 @@
package com.frank.camerafilter.filter.advance; package com.frank.camerafilter.filter.advance;
import android.content.Context; import android.content.Context;
import android.opengl.GLES20; import android.opengl.GLES30;
import com.frank.camerafilter.R; import com.frank.camerafilter.R;
import com.frank.camerafilter.filter.BaseFilter; import com.frank.camerafilter.filter.BaseFilter;
@ -18,8 +18,8 @@ public class BeautySketchFilter extends BaseFilter {
protected void onInit() { protected void onInit() {
super.onInit(); super.onInit();
strengthLocation = GLES20.glGetUniformLocation(getProgramId(), "strength"); strengthLocation = GLES30.glGetUniformLocation(getProgramId(), "strength");
stepOffsetLocation = GLES20.glGetUniformLocation(getProgramId(), "singleStepOffset"); stepOffsetLocation = GLES30.glGetUniformLocation(getProgramId(), "singleStepOffset");
} }
@Override @Override

@ -7,7 +7,25 @@ varying mediump vec2 textureCoordinate;
uniform samplerExternalOES inputImageTexture; uniform samplerExternalOES inputImageTexture;
void main(){ void main(){
vec2 xy = textureCoordinate.xy;
// two screen(0.25~0.75)
// if (xy.x <= 0.5) {
// xy.x += 0.25;
// } else {
// xy.x -= 0.25;
// }
// four screen
// if (xy.x <= 0.5) {
// xy.x = xy.x * 2.0;
// } else {
// xy.x = (xy.x - 0.5) * 2.0;
// }
// if (xy.y <= 0.5) {
// xy.y = xy.y * 2.0;
// } else {
// xy.y = (xy.y - 0.5) * 2.0;
// }
vec3 centralColor = texture2D(inputImageTexture, textureCoordinate).rgb; vec3 centralColor = texture2D(inputImageTexture, xy).rgb;
gl_FragColor = vec4(centralColor.rgb,1.0); gl_FragColor = vec4(centralColor.rgb,1.0);
} }
Loading…
Cancel
Save