• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform half4 testInputs;
2uniform half4 colorGreen, colorRed;
3
4half4 main(float2 coords) {
5    half4 expectedA       = half4(-1,     0,  0.75, 1);
6
7    const half4 clampLow  = half4(-1,    -2, -2,    1);
8    const half4 constVal  = half4(-1.25,  0,  0.75, 2.25);
9    half4 expectedB       = half4(-1,     0,  0.5,  2.25);
10    const half4 clampHigh = half4( 1,     2,  0.5,  3);
11
12    return (clamp(testInputs.x,    -1, 1)                         == expectedA.x     &&
13            clamp(testInputs.xy,   -1, 1)                         == expectedA.xy    &&
14            clamp(testInputs.xyz,  -1, 1)                         == expectedA.xyz   &&
15            clamp(testInputs.xyzw, -1, 1)                         == expectedA.xyzw  &&
16            clamp(constVal.x,      -1, 1)                         == expectedA.x     &&
17            clamp(constVal.xy,     -1, 1)                         == expectedA.xy    &&
18            clamp(constVal.xyz,    -1, 1)                         == expectedA.xyz   &&
19            clamp(constVal.xyzw,   -1, 1)                         == expectedA.xyzw  &&
20            clamp(testInputs.x,    clampLow.x,    clampHigh.x   ) == expectedB.x     &&
21            clamp(testInputs.xy,   clampLow.xy,   clampHigh.xy  ) == expectedB.xy    &&
22            clamp(testInputs.xyz,  clampLow.xyz,  clampHigh.xyz ) == expectedB.xyz   &&
23            clamp(testInputs.xyzw, clampLow.xyzw, clampHigh.xyzw) == expectedB.xyzw  &&
24            clamp(constVal.x,      clampLow.x,    clampHigh.x   ) == expectedB.x     &&
25            clamp(constVal.xy,     clampLow.xy,   clampHigh.xy  ) == expectedB.xy    &&
26            clamp(constVal.xyz,    clampLow.xyz,  clampHigh.xyz ) == expectedB.xyz   &&
27            clamp(constVal.xyzw,   clampLow.xyzw, clampHigh.xyzw) == expectedB.xyzw) ? colorGreen
28                                                                                     : colorRed;
29}
30