/usr/share/psychtoolbox-3/PsychOpenGL/PsychGLSLShaders/Convolve2DRectTexture1ChannelShader.frag.txt is in psychtoolbox-3-common 3.0.11.20140816.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* Generic 2D convolution fragment shader for 2D rectangle textures.
// OpenGL program has to setup the texture unit 'Kernel' with a lookup
// table texture for the coefficients of the convolution kernel and bind
// texture unit 'Image' with the image to be convoluted. Texture filtering
// mode needs to be GL_NEAREST for defined results! The half width of the
// convolution kernel needs to be provided in the uniform 'KernelHalfWidthX'
// and 'KernelHalfWidthY' for x and y half-width.
//
// Please note that it is more efficient to provide the convolution kernel
// in an array of uniforms or compiled into the shader. This is less flexible
// as it doesn't allow to change kernels on the fly and it only works for a
// rather limited kernel size of say 15 by 15 on Geforce 7000 class hardware,
// but it is significantly faster if it can be used.
//
// (w)2006 by Mario Kleiner. Licensed under MIT license.
*/
#extension GL_ARB_texture_rectangle : enable
uniform float KernelHalfWidthX;
uniform float KernelHalfWidthY;
uniform sampler2DRect Image;
uniform sampler2DRect Kernel;
void main()
{
float dx, dy;
float sum = float(0.0);
float tmp;
float kernelvalue;
for (dy = -KernelHalfWidthY; dy <= KernelHalfWidthY; dy++) {
for (dx = -KernelHalfWidthX; dx <= KernelHalfWidthX; dx++) {
kernelvalue = texture2DRect(Kernel, vec2(dx + KernelHalfWidthX, dy + KernelHalfWidthY)).r;
tmp = texture2DRect(Image, gl_TexCoord[0].st + vec2(dx, dy)).r;
sum += tmp * kernelvalue;
}
}
gl_FragColor.rgb = vec3(sum);
gl_FragColor.a = texture2DRect(Image, gl_TexCoord[0].st).a;
}
|