diff --git a/README.md b/README.md index 3d3d8fe..2f26118 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,5 @@ Realtime camera filters. Process frames by OpenGL shaders. | Lichtenstein-esque | https://www.shadertoy.com/view/Mdf3zS | ![](art/15.png) | | Ascii Art | https://www.shadertoy.com/view/lssGDj# | ![](art/16.png) | | Money Filter | https://www.shadertoy.com/view/XlsXDN | ![](art/17.png) | +| Cracked | https://www.shadertoy.com/view/XdBSzW | ![](art/18.png) | +| Polygonization | https://www.shadertoy.com/view/4lsXR7# | ![](art/19.png) | \ No newline at end of file diff --git a/app/src/main/java/cn/nekocode/camerafilter/CameraRenderer.java b/app/src/main/java/cn/nekocode/camerafilter/CameraRenderer.java index 65b5d92..76f5075 100644 --- a/app/src/main/java/cn/nekocode/camerafilter/CameraRenderer.java +++ b/app/src/main/java/cn/nekocode/camerafilter/CameraRenderer.java @@ -23,6 +23,7 @@ import cn.nekocode.camerafilter.filter.CameraFilter; import cn.nekocode.camerafilter.filter.ChromaticAberrationFilter; import cn.nekocode.camerafilter.filter.ContrastFilter; +import cn.nekocode.camerafilter.filter.CrackedFilter; import cn.nekocode.camerafilter.filter.CrosshatchFilter; import cn.nekocode.camerafilter.filter.EMInterferenceFilter; import cn.nekocode.camerafilter.filter.EdgeDetectionFilter; @@ -33,6 +34,7 @@ import cn.nekocode.camerafilter.filter.NoiseWarpFilter; import cn.nekocode.camerafilter.filter.OriginalFilter; import cn.nekocode.camerafilter.filter.PixelizeFilter; +import cn.nekocode.camerafilter.filter.PolygonizationFilter; import cn.nekocode.camerafilter.filter.RefractionFilter; import cn.nekocode.camerafilter.filter.TileMosaicFilter; import cn.nekocode.camerafilter.filter.TrianglesMosaicFilter; @@ -128,6 +130,8 @@ public void run() { cameraFilterMap.append(R.id.filter15, new LichtensteinEsqueFilter(context)); cameraFilterMap.append(R.id.filter16, new AsciiArtFilter(context)); cameraFilterMap.append(R.id.filter17, new MoneyFilter(context)); + cameraFilterMap.append(R.id.filter18, new CrackedFilter(context)); + cameraFilterMap.append(R.id.filter19, new PolygonizationFilter(context)); cameraFilter = cameraFilterMap.get(R.id.filter0); try { diff --git a/app/src/main/java/cn/nekocode/camerafilter/filter/CrackedFilter.java b/app/src/main/java/cn/nekocode/camerafilter/filter/CrackedFilter.java new file mode 100644 index 0000000..b22bf16 --- /dev/null +++ b/app/src/main/java/cn/nekocode/camerafilter/filter/CrackedFilter.java @@ -0,0 +1,25 @@ +package cn.nekocode.camerafilter.filter; + +import android.content.Context; + +import cn.nekocode.camerafilter.MyGLUtils; +import cn.nekocode.camerafilter.R; + +/** + * Created by nekocode on 16/8/6. + */ +public class CrackedFilter extends CameraFilter { + private int program; + + public CrackedFilter(Context context) { + super(context); + + // Build shaders + program = MyGLUtils.buildProgram(context, R.raw.vertext, R.raw.cracked); + } + + @Override + public void draw(int textureId, int gwidth, int gheight) { + defaultDraw(program, textureId, gwidth, gheight); + } +} diff --git a/app/src/main/java/cn/nekocode/camerafilter/filter/PolygonizationFilter.java b/app/src/main/java/cn/nekocode/camerafilter/filter/PolygonizationFilter.java new file mode 100644 index 0000000..c6baab9 --- /dev/null +++ b/app/src/main/java/cn/nekocode/camerafilter/filter/PolygonizationFilter.java @@ -0,0 +1,25 @@ +package cn.nekocode.camerafilter.filter; + +import android.content.Context; + +import cn.nekocode.camerafilter.MyGLUtils; +import cn.nekocode.camerafilter.R; + +/** + * Created by nekocode on 16/8/6. + */ +public class PolygonizationFilter extends CameraFilter { + private int program; + + public PolygonizationFilter(Context context) { + super(context); + + // Build shaders + program = MyGLUtils.buildProgram(context, R.raw.vertext, R.raw.polygonization); + } + + @Override + public void draw(int textureId, int gwidth, int gheight) { + defaultDraw(program, textureId, gwidth, gheight); + } +} diff --git a/app/src/main/res/menu/filter.xml b/app/src/main/res/menu/filter.xml index c955dac..47ad3ce 100644 --- a/app/src/main/res/menu/filter.xml +++ b/app/src/main/res/menu/filter.xml @@ -109,4 +109,16 @@ android:title="MoneyFilter" app:showAsAction="never" /> + + + + diff --git a/app/src/main/res/raw/cracked.fsh b/app/src/main/res/raw/cracked.fsh new file mode 100644 index 0000000..bebc488 --- /dev/null +++ b/app/src/main/res/raw/cracked.fsh @@ -0,0 +1,49 @@ +#extension GL_OES_EGL_image_external : require +precision highp float; + +uniform vec3 iResolution; +uniform float iGlobalTime; +uniform samplerExternalOES sTexture; +varying vec2 texCoord; + +float rnd(vec2 s) +{ + return 1.-2.*fract(sin(s.x*253.13+s.y*341.41)*589.19); +} + +void mainImage( out vec4 fragColor, in vec2 fragCoord ) +{ + vec2 p=(fragCoord.xy*2.-iResolution.xy)/iResolution.x; + + vec2 v=vec2(1E3); + vec2 v2=vec2(1E4); + vec2 center=vec2(.1,-.5); + for(int c=0;c<30;c++) + { + float angle=floor(rnd(vec2(float(c),387.44))*16.)*3.1415*.4-.5; + float dist=pow(rnd(vec2(float(c),78.21)),2.)*.5; + vec2 vc=vec2(center.x+cos(angle)*dist+rnd(vec2(float(c),349.3))*7E-3, + center.y+sin(angle)*dist+rnd(vec2(float(c),912.7))*7E-3); + if(length(vc-p)