File: ICMCheckedPassThroughShader.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-- 1,112 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
/* Shader for color checking of RGB and luminance textures.
 *
 * Clamps all color or intensity values to lie in the range given
 * by [ ICMClampToColorRange[0]; ICMClampToColorRange[1] ]. If values were
 * outside that range, they will be inverted and mapped to values 0.0 or 1.0.
 *
 * (w)2008 by Mario Kleiner. Licensed under MIT license.
*/

/* Allowable range: To be initialized by PsychColorCorrection() typically: */
uniform vec2    ICMClampToColorRange;

vec4 icmTransformColor(vec4 incolor)
{
    if (incolor.r < ICMClampToColorRange[0]) incolor.r = 1.0;
    if (incolor.r > ICMClampToColorRange[1]) incolor.r = 0.0;
    if (incolor.g < ICMClampToColorRange[0]) incolor.g = 1.0;
    if (incolor.g > ICMClampToColorRange[1]) incolor.g = 0.0;
    if (incolor.b < ICMClampToColorRange[0]) incolor.b = 1.0;
    if (incolor.b > ICMClampToColorRange[1]) incolor.b = 0.0;

    return(incolor);
}

float icmTransformColor1(float incolor)
{
    if (incolor < ICMClampToColorRange[0]) incolor = 1.0;
    if (incolor > ICMClampToColorRange[1]) incolor = 0.0;

    return(incolor);
}