File: SeparateAlphaTextureShader.frag.txt

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (31 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (7)
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
/*
 * File: SeparateAlphaTextureShader.frag.txt
 * Shader for drawing of textures where the alpha channel is looked up
 * separately from the RGB channels, i.e. RGB texel lookup uses texture
 * coordinates offset by given optional shift parameters.
 *
 * (c) 2009 by Mario Kleiner, licensed under MIT license.
 *		 
 */

#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect Image;
uniform vec4 Offset;

varying vec4 baseColor;

void main()
{
    /* Read alpha channel value from standard texture coordinate set: */
    float alpha = texture2DRect(Image, gl_TexCoord[0].st).a;

    /* Read RGB color values from secondary texture coordinate set: */
    vec3 rgb    = texture2DRect(Image, gl_TexCoord[1].st).rgb;

    /* Assemble back into RGBA quadruple: */
    vec4 rgba   = vec4(rgb, alpha);

    /* ... and output to framebuffer, with proper modulation and offset applied: */
    gl_FragColor = (baseColor * rgba) + Offset;
}