[GEM-dev] Guassian Blur pixel shader?

chris clepper cgc at humboldtblvd.com
Thu Feb 16 19:09:33 CET 2006


Not tested in GEM but this is working GLSL code from ATI for a type of
Gaussian effect:

vertex shader:

varying vec2 texCoordM;
varying vec2 texCoordB0;
varying vec2 texCoordF0;
varying vec2 texCoordB1;
varying vec2 texCoordF1;
varying vec2 texCoordB2;
varying vec2 texCoordF2;

void main(){
	gl_Position = gl_Vertex;
	vec2 texCoord = gl_MultiTexCoord0.xy;

	vec2 invSize = vec2 (0.99);

	texCoordM = texCoord;
	texCoordB0 = texCoord - invSize;
	texCoordF0 = texCoord + invSize;
	texCoordB1 = texCoord - invSize * 2.0;
	texCoordF1 = texCoord + invSize * 2.0;
	texCoordB2 = texCoord - invSize * 3.0;
	texCoordF2 = texCoord + invSize * 3.0;
}

fragment shader:

uniform sampler2D Image;

varying vec2 texCoordM;
varying vec2 texCoordB0;
varying vec2 texCoordF0;
varying vec2 texCoordB1;
varying vec2 texCoordF1;
varying vec2 texCoordB2;
varying vec2 texCoordF2;

void main(){
	vec4 sampleM  = texture2D(Image, texCoordM);
	vec4 sampleB0 = texture2D(Image, texCoordB0);
	vec4 sampleF0 = texture2D(Image, texCoordF0);
	vec4 sampleB1 = texture2D(Image, texCoordB1);
	vec4 sampleF1 = texture2D(Image, texCoordF1);
	vec4 sampleB2 = texture2D(Image, texCoordB2);
	vec4 sampleF2 = texture2D(Image, texCoordF2);

	gl_FragColor = 0.1752 * sampleM + 0.1658 * (sampleB0 + sampleF0) +
0.1403 * (sampleB1 + sampleF1) + 0.1063 * (sampleB2 + sampleF2);
}

Post back a working patch if you get one going.  Good luck!

cgc

On 2/16/06, B. Bogart <ben at ekran.org> wrote:
> Hey all,
>
> Now that I have Gem actually compiling again on my linux machine I
> wonder if my dream of a realtime blur could be a reality with
> pixelshaders. :) Anyhow know of some extreme blurring I can apply as a
> pixelshader to a texture loaded in gem?
>
> Thanks Johannes for the help with the Gem compile. I remember why I
> needed to recompile it, to test the v4l2 support. I'll do that today and
> report back.
>
> .b.
>
>
> _______________________________________________
> GEM-dev mailing list
> GEM-dev at iem.at
> http://lists.puredata.info/listinfo/gem-dev
>
>
>
>




More information about the GEM-dev mailing list