From 55f034aa5ca00969f6b50431dc66b97cb1d68614 Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Wed, 19 Oct 2022 17:06:59 +0800 Subject: [PATCH] Feature: change GLES2.0 to GLES3.0 --- .../filter/advance/BeautySketchFilter.java | 6 +++--- .../src/main/res/raw/default_fragment.glsl | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautySketchFilter.java b/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautySketchFilter.java index 8836966..47e4dde 100644 --- a/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautySketchFilter.java +++ b/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautySketchFilter.java @@ -1,7 +1,7 @@ package com.frank.camerafilter.filter.advance; import android.content.Context; -import android.opengl.GLES20; +import android.opengl.GLES30; import com.frank.camerafilter.R; import com.frank.camerafilter.filter.BaseFilter; @@ -18,8 +18,8 @@ public class BeautySketchFilter extends BaseFilter { protected void onInit() { super.onInit(); - strengthLocation = GLES20.glGetUniformLocation(getProgramId(), "strength"); - stepOffsetLocation = GLES20.glGetUniformLocation(getProgramId(), "singleStepOffset"); + strengthLocation = GLES30.glGetUniformLocation(getProgramId(), "strength"); + stepOffsetLocation = GLES30.glGetUniformLocation(getProgramId(), "singleStepOffset"); } @Override diff --git a/CameraFilter/src/main/res/raw/default_fragment.glsl b/CameraFilter/src/main/res/raw/default_fragment.glsl index c3c80cb..7dbf126 100644 --- a/CameraFilter/src/main/res/raw/default_fragment.glsl +++ b/CameraFilter/src/main/res/raw/default_fragment.glsl @@ -7,7 +7,25 @@ varying mediump vec2 textureCoordinate; uniform samplerExternalOES inputImageTexture; 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); } \ No newline at end of file