Loading media/mca/filterpacks/java/android/filterpacks/imageproc/BlackWhiteFilter.java +5 −36 Original line number Original line Diff line number Diff line Loading @@ -47,20 +47,19 @@ public class BlackWhiteFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame = null; private Random mRandom; private final String mBlackWhiteShader = private final String mBlackWhiteShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float black;\n" + "uniform float black;\n" + "uniform float scale;\n" + "uniform float scale;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp((color.rgb - black) * scale, 0.0, 1.0);\n" + " vec3 xform = clamp((color.rgb - black) * scale, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - black) * scale, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - black) * scale, 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -69,8 +68,6 @@ public class BlackWhiteFilter extends Filter { public BlackWhiteFilter(String name) { public BlackWhiteFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -84,14 +81,6 @@ public class BlackWhiteFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -139,33 +128,13 @@ public class BlackWhiteFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); if (mNoiseFrame != null) { mNoiseFrame.release(); } int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading media/mca/filterpacks/java/android/filterpacks/imageproc/DocumentaryFilter.java +5 −36 Original line number Original line Diff line number Diff line Loading @@ -41,21 +41,20 @@ public class DocumentaryFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame; private Random mRandom; private final String mDocumentaryShader = private final String mDocumentaryShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "uniform float inv_max_dist;\n" + "uniform float inv_max_dist;\n" + "uniform vec2 center;\n" + "uniform vec2 center;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + // black white // black white " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp(2.0 * color.rgb, 0.0, 1.0);\n" + " vec3 xform = clamp(2.0 * color.rgb, 0.0, 1.0);\n" + " vec3 temp = clamp(2.0 * (color.rgb + stepsize), 0.0, 1.0);\n" + " vec3 temp = clamp(2.0 * (color.rgb + stepsize), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -70,8 +69,6 @@ public class DocumentaryFilter extends Filter { public DocumentaryFilter(String name) { public DocumentaryFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -85,14 +82,6 @@ public class DocumentaryFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -123,34 +112,14 @@ public class DocumentaryFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); if (mNoiseFrame != null) { mNoiseFrame.release(); } mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); initParameters(); initParameters(); } } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading media/mca/filterpacks/java/android/filterpacks/imageproc/LomoishFilter.java +5 −38 Original line number Original line Diff line number Diff line Loading @@ -28,8 +28,6 @@ import android.filterfw.core.Program; import android.filterfw.core.ShaderProgram; import android.filterfw.core.ShaderProgram; import android.filterfw.format.ImageFormat; import android.filterfw.format.ImageFormat; import java.util.Random; public class LomoishFilter extends Filter { public class LomoishFilter extends Filter { @GenerateFieldPort(name = "tile_size", hasDefault = true) @GenerateFieldPort(name = "tile_size", hasDefault = true) Loading @@ -41,19 +39,18 @@ public class LomoishFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame; private Random mRandom; private final String mLomoishShader = private final String mLomoishShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float stepsizeX;\n" + "uniform float stepsizeX;\n" + "uniform float stepsizeY;\n" + "uniform float stepsizeY;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "uniform vec2 center;\n" + "uniform vec2 center;\n" + "uniform float inv_max_dist;\n" + "uniform float inv_max_dist;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + // sharpen // sharpen " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" + " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" + Loading Loading @@ -99,7 +96,7 @@ public class LomoishFilter extends Filter { " }\n" + " }\n" + " c_color.b = s_color.b * 0.5 + 0.25;\n" + " c_color.b = s_color.b * 0.5 + 0.25;\n" + // blackwhite // blackwhite " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp((c_color.rgb - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 xform = clamp((c_color.rgb - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 bw_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 bw_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -111,8 +108,6 @@ public class LomoishFilter extends Filter { public LomoishFilter(String name) { public LomoishFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -126,14 +121,6 @@ public class LomoishFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -180,34 +167,14 @@ public class LomoishFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); if (mNoiseFrame != null) { mNoiseFrame.release(); } mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); initParameters(); initParameters(); } } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading Loading
media/mca/filterpacks/java/android/filterpacks/imageproc/BlackWhiteFilter.java +5 −36 Original line number Original line Diff line number Diff line Loading @@ -47,20 +47,19 @@ public class BlackWhiteFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame = null; private Random mRandom; private final String mBlackWhiteShader = private final String mBlackWhiteShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float black;\n" + "uniform float black;\n" + "uniform float scale;\n" + "uniform float scale;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp((color.rgb - black) * scale, 0.0, 1.0);\n" + " vec3 xform = clamp((color.rgb - black) * scale, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - black) * scale, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - black) * scale, 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -69,8 +68,6 @@ public class BlackWhiteFilter extends Filter { public BlackWhiteFilter(String name) { public BlackWhiteFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -84,14 +81,6 @@ public class BlackWhiteFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -139,33 +128,13 @@ public class BlackWhiteFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); if (mNoiseFrame != null) { mNoiseFrame.release(); } int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading
media/mca/filterpacks/java/android/filterpacks/imageproc/DocumentaryFilter.java +5 −36 Original line number Original line Diff line number Diff line Loading @@ -41,21 +41,20 @@ public class DocumentaryFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame; private Random mRandom; private final String mDocumentaryShader = private final String mDocumentaryShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "uniform float inv_max_dist;\n" + "uniform float inv_max_dist;\n" + "uniform vec2 center;\n" + "uniform vec2 center;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + // black white // black white " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" + " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp(2.0 * color.rgb, 0.0, 1.0);\n" + " vec3 xform = clamp(2.0 * color.rgb, 0.0, 1.0);\n" + " vec3 temp = clamp(2.0 * (color.rgb + stepsize), 0.0, 1.0);\n" + " vec3 temp = clamp(2.0 * (color.rgb + stepsize), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -70,8 +69,6 @@ public class DocumentaryFilter extends Filter { public DocumentaryFilter(String name) { public DocumentaryFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -85,14 +82,6 @@ public class DocumentaryFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -123,34 +112,14 @@ public class DocumentaryFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); if (mNoiseFrame != null) { mNoiseFrame.release(); } mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); initParameters(); initParameters(); } } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading
media/mca/filterpacks/java/android/filterpacks/imageproc/LomoishFilter.java +5 −38 Original line number Original line Diff line number Diff line Loading @@ -28,8 +28,6 @@ import android.filterfw.core.Program; import android.filterfw.core.ShaderProgram; import android.filterfw.core.ShaderProgram; import android.filterfw.format.ImageFormat; import android.filterfw.format.ImageFormat; import java.util.Random; public class LomoishFilter extends Filter { public class LomoishFilter extends Filter { @GenerateFieldPort(name = "tile_size", hasDefault = true) @GenerateFieldPort(name = "tile_size", hasDefault = true) Loading @@ -41,19 +39,18 @@ public class LomoishFilter extends Filter { private int mHeight = 0; private int mHeight = 0; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private int mTarget = FrameFormat.TARGET_UNSPECIFIED; private Frame mNoiseFrame; private Random mRandom; private final String mLomoishShader = private final String mLomoishShader = "precision mediump float;\n" + "precision mediump float;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_0;\n" + "uniform sampler2D tex_sampler_1;\n" + "uniform float stepsizeX;\n" + "uniform float stepsizeX;\n" + "uniform float stepsizeY;\n" + "uniform float stepsizeY;\n" + "uniform float stepsize;\n" + "uniform float stepsize;\n" + "uniform vec2 center;\n" + "uniform vec2 center;\n" + "uniform float inv_max_dist;\n" + "uniform float inv_max_dist;\n" + "varying vec2 v_texcoord;\n" + "varying vec2 v_texcoord;\n" + "float rand(vec2 loc) {\n" + " return fract(sin(dot(loc, vec2(12.9898, 78.233))) * 43758.5453);\n" + "}\n" + "void main() {\n" + "void main() {\n" + // sharpen // sharpen " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" + " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" + Loading Loading @@ -99,7 +96,7 @@ public class LomoishFilter extends Filter { " }\n" + " }\n" + " c_color.b = s_color.b * 0.5 + 0.25;\n" + " c_color.b = s_color.b * 0.5 + 0.25;\n" + // blackwhite // blackwhite " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" + " float dither = rand(v_texcoord);\n" + " vec3 xform = clamp((c_color.rgb - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 xform = clamp((c_color.rgb - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 temp = clamp((color.rgb + stepsize - 0.15) * 1.53846, 0.0, 1.0);\n" + " vec3 bw_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + " vec3 bw_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" + Loading @@ -111,8 +108,6 @@ public class LomoishFilter extends Filter { public LomoishFilter(String name) { public LomoishFilter(String name) { super(name); super(name); mRandom = new Random(); } } @Override @Override Loading @@ -126,14 +121,6 @@ public class LomoishFilter extends Filter { return inputFormat; return inputFormat; } } @Override public void tearDown(FilterContext context) { if (mNoiseFrame != null) { mNoiseFrame.release(); mNoiseFrame = null; } } public void initProgram(FilterContext context, int target) { public void initProgram(FilterContext context, int target) { switch (target) { switch (target) { case FrameFormat.TARGET_GPU: case FrameFormat.TARGET_GPU: Loading Loading @@ -180,34 +167,14 @@ public class LomoishFilter extends Filter { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); mHeight = inputFormat.getHeight(); int[] buffer = new int[mWidth * mHeight]; for (int i = 0; i < mWidth * mHeight; ++i) { buffer[i] = mRandom.nextInt(255); } FrameFormat format = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU); if (mNoiseFrame != null) { mNoiseFrame.release(); } mNoiseFrame = context.getFrameManager().newFrame(format); mNoiseFrame.setInts(buffer); initParameters(); initParameters(); } } if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth || mNoiseFrame.getFormat().getHeight() != mHeight)) { throw new RuntimeException("Random map and imput image size mismatch!"); } // Create output frame // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); Frame output = context.getFrameManager().newFrame(inputFormat); // Process // Process Frame[] inputs = {input, mNoiseFrame}; mProgram.process(input, output); mProgram.process(inputs, output); // Push output // Push output pushOutput("image", output); pushOutput("image", output); Loading