File: ColoredSingleChannelAnaglyphShader.frag.txt

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (41 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (6)
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
/* ColoredSingleChannelAnaglyphShader.frag.txt
 *
 * A more complex conversion shader for color anaglyphs than the one
 * hard-wired into PTBs Screen command. Applies full 3x3 color gain
 * matrix to color of one view channel, then optionally applies
 * gamma correction to the red output channel.
 *
 * Standard anaglyph conversion is implemented by the default shader in
 * Screen() and can be parameterized by SetAnaglyphStereoParameters.
 *
 * This shader is used for more complex/exotic ways of anaglyph conversion.
 *
 * Loaded/initialized by PsychColorCorrection.m as part of
 * the PTB imaging pipeline color anaglyph shading support.
 * Parameterized by SetAnaglyphStereoParameters.
 *
 * (C) 2012 Mario Kleiner - Released to you under MIT license.
 */

/* 3 by 3 color gain matrices, always denoted GainsLeft, even for right channel: */
uniform mat3 GainsLeft;

/* Gamma value for red out channel - Set zero for no gamma correction! */
uniform float RedGamma;

vec4 icmTransformColor(vec4 incolor)
{
    vec4 outcolor;

    /* Multiply first 3 vector components with matrix: */
    outcolor.rgb = GainsLeft * incolor.rgb;

    /* Alpha is passed through unmodified: */
    outcolor.a = incolor.a;

    /* Apply gamma correction to red channel, if requested: */
    /* Note: This op is expensive on GPUs without dynamic flow control! */
    if (RedGamma > 0.0) outcolor.r = pow(outcolor.r, RedGamma);

    return(outcolor);
}