BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.21k stars 4.61k forks source link

Kawase Blur Problem #2534

Closed oguzgu closed 6 years ago

oguzgu commented 6 years ago

Hi,

I added a custom kawase blur filter to my project.

` precision highp float;

varying lowp vec2 textureCoordinate; uniform sampler2D inputImageTexture;

vec4 KawaseBlur(vec2 pixelSize, int iteration, vec2 halfSize, vec2 uv) { vec2 dUV = (pixelSize * float(iteration)) + halfSize;

vec2 texcoord;

texcoord.x = uv.x - dUV.x;
texcoord.y = uv.y + dUV.y;

vec4 color = texture2D(inputImageTexture, texcoord);

texcoord.x = uv.x + dUV.x;
texcoord.y = uv.y + dUV.y;

color += texture2D(inputImageTexture, texcoord);

texcoord.x = uv.x - dUV.x;
texcoord.y = uv.y - dUV.y;

color += texture2D(inputImageTexture, texcoord);

texcoord.x = uv.x + dUV.x;
texcoord.y = uv.y - dUV.y;

color += texture2D(inputImageTexture, texcoord);

color.rgb *= 0.25;

return color;

}

void main() {

 int Iterations = 1;

 // fixed resolution
 // test for iphone 6
 vec2 iResolution = vec2(750.0, 1334.0);

 vec2 uv = textureCoordinate / iResolution;
 uv.y = -uv.y;

 vec2 pixelSize = vec2(1.0) / iResolution;
 vec2 halfSize = pixelSize / vec2(2.0);

 vec4 color = vec4(0);

 for(int i = 1; i <= Iterations; i++)
 {
     color =  KawaseBlur(pixelSize, i, halfSize, uv);
 }
 gl_FragColor = color;

} `

But it is not working properly, it shows only white screen when camera capture started, then only shows a few colors whem moving camera.

How can i solve this problem?