/usr/share/psychtoolbox-3/PsychOpenGL/PsychGLSLShaders/moglTextureExtractionShader.frag.txt is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* Shader for extraction of 3D object textures from video input images.
* Used by PTB function moglExtractTexture.m
*
* (c) 2009 by Mario Kleiner, licensed under MIT license.
*/
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect InputImage;
uniform sampler2DRect GeometryBuffer;
uniform sampler2DRect Silhouette;
uniform float zThreshold;
uniform float ViewportHeight;
uniform vec2 texWrapAround;
void main(void)
{
/* texinpos is our (x,y) readposition in GeometryBuffer: */
/* We use bilinear filtering to reduce aliasing artifacts when reading from this buffer: */
vec2 texinpos = gl_FragCoord.xy; /* gl_TexCoord[0].st; */
vec4 tl=texture2DRect(GeometryBuffer, mod(floor(texinpos), texWrapAround));
vec4 tr=texture2DRect(GeometryBuffer, mod(floor(texinpos) + vec2(1.0, 0.0), texWrapAround));
vec4 bl=texture2DRect(GeometryBuffer, mod(floor(texinpos) + vec2(0.0, 1.0), texWrapAround));
vec4 br=texture2DRect(GeometryBuffer, mod(floor(texinpos) + vec2(1.0, 1.0), texWrapAround));
/* Perform weighted linear interpolation -- bilinear interpolation of the 4: */
tl=mix(tl,tr,fract(texinpos.x));
bl=mix(bl,br,fract(texinpos.x));
/* position is our image space 4D (x,y,z,w) position to extract color data from: */
vec4 position = mix(tl, bl, fract(texinpos.y));
/* position.xyz = position.xyz / position.w; */
/* Potential zpos from GeometryBuffer, iff surface location 'position' is not occluded: */
float zpos = position.z;
/* Reference zdepth from Silhouette buffer - Our depth buffer for occlusion handling: */
float refz = texture2DRect(Silhouette, position.xy).a;
/* Check for occlusion - Discard this sample if z-values do not match -> Occluded: */
if ((texture2DRect(Silhouette, position.xy).b == 0.0)|| (position.w == 0.0) || (abs(zpos - refz) > zThreshold)) {
/* Discard this fragment: We write an all-black pixel */
gl_FragColor = vec4(0.0);
}
else {
/* Readout image pixel color in input image texture at location position.xy, write it to target buffer: */
/* gl_FragColor.rgb = texture2DRect(InputImage, vec2(position.x, ViewportHeight - position.y)).rgb; */
gl_FragColor.rgb = texture2DRect(InputImage, position.xy).rgb;
/* Set alpha channel to 1.0 to mark this texel as valid: */
gl_FragColor.a = 1.0;
}
}
|