[Fluxus] shaders on os x
Dave Griffiths
dave at pawfal.org
Tue Jan 12 01:51:24 PST 2010
On Sun, 2010-01-10 at 15:52 +0000, evan.raskob [lists] wrote:
> hey gang,
>
> has anyone got a shader working for manipulating a texture on os x
> (gaussian blur, or enhance, or some other effect)? can i take a peek
> at the code? having some trouble getting it to work over here and not
> sure where the errors are.
Try these:
---- bloom.vert.glsl -----------------------------------------------
varying vec2 texc;
void main()
{
// apply the normal gl modelviewprojection to the vertex
gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
texc = vec2(gl_MultiTexCoord0);
}
---- bloom.frag.glsl -----------------------------------------------
varying vec2 texc;
uniform sampler2D tex;
uniform float kernel;
uniform float scale;
uniform float thresh;
void main()
{
vec4 sum = vec4(0);
int i=0;
// mess of for loops due to gpu compiler/hardware limitations
int j=-2;
for(i=-2; i<=2; i++) sum+=texture2D(tex,texc+vec2(i,j)*kernel);
j=-1;
for(i=-2; i<=2; i++) sum+=texture2D(tex,texc+vec2(i,j)*kernel);
j=0;
for(i=-2; i<=2; i++) sum+=texture2D(tex,texc+vec2(i,j)*kernel);
j=1;
for(i=-2; i<=2; i++) sum+=texture2D(tex,texc+vec2(i,j)*kernel);
j=2;
for(i=-2; i<=2; i++) sum+=texture2D(tex,texc+vec2(i,j)*kernel);
sum/=25.0;
vec4 s=texture2D(tex, texc);
gl_FragColor=s;
// use the blurred colour if it's bright enough
if (length(sum)>thresh)
{
gl_FragColor=sum*scale;
}
}
More information about the Fluxus
mailing list