File: Bits%2B%2B_Mono%2B%2B_LUTFormattingShader.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 (42 lines) | stat: -rw-r--r-- 1,646 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
32
33
34
35
36
37
38
39
40
41
42
/* Bits++_Mono++_FormattingShader.frag.txt -- Mono++ output formatter
 *
 * This shader converts a HDR texture into a RGBA8 8bpc framebuffer
 * image, suitable for display with the CRS Bits++ system in Mono++
 * mode. It expects the luminance image data in the red channel of
 * the texture, with values ranging from 0.0 - 1.0, remaps it into
 * the 16 bit data range of Bits++, then encodes the 16 bit luminance
 * value into the red+green channels (8 MSB in red, 8 LSB in green). The
 * blue channel is set to 0.0, i.e., black. The alpha channel is set to
 * a fixed maximum value of 1.0, because alpha blending on such an image
 * would be an undefined operation.
 *
 * This shader is intended for use as a plugin for the 'FinalOutputFormattingBlit'
 * chain of the Psychtoolbox-3 imaging pipeline.
 *
 * (c)2007 by Mario Kleiner, part of PTB-3, licensed to you under MIT license.
 * See file License.txt in the Psychtoolbox root folder for the license.
 *
 */

#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect Image;
uniform sampler1D moduloLUT;

void main()
{
    /* Retrieve RGBA HDR input color value. */
    float incolor = texture2DRect(Image, gl_TexCoord[0].st).r;

    /* Remap red channel from 0.0 - 1.0 to 0 to 65535: */
    float index = (incolor * 65535.0) / 256.0;

    /* Compute high byte (8 MSBs) and store in red output color. */
    gl_FragColor.r = floor(index) / 255.0;

    /* Compute low byte (8 LSBs) and store in green output color. */
    gl_FragColor.g = texture1D(moduloLUT, mod(index, 1.0)).r;

    /* Fix blue channel to 0.0, fix alpha channel to 1.0. */
    gl_FragColor.ba = vec2(0.0, 1.0);
}