blob: 421956e0306b3ddda4f2cd4dc505e9c8f7305c91 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
<languageVersion : 1.0;>
kernel Int2
< namespace : "testing";
vendor : "Apache";
version : 1;
description : "Int2 without a default.";
>
{
input image4 src;
output pixel4 dst;
parameter int2 theInt
<
minValue:int2(0,0);
maxValue:int2(7,7);
>;
void
evaluatePixel()
{
float2 pos = outCoord();
float x = pos.x;
float y = pos.y;
// Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0.
int int1bit1 = (theInt.x == 1 || theInt.x == 3 || theInt.x == 5 || theInt.x == 7) ? 1 : 0;
int int1bit2 = (theInt.x == 2 || theInt.x == 3 || theInt.x == 6 || theInt.x == 7) ? 1 : 0;
int int1bit3 = (theInt.x >= 4) ? 1 : 0;
float4 int1bit1Bounds;
float4 int1bit2Bounds;
float4 int1bit3Bounds;
// Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0.
int int2bit1 = (theInt.y == 1 || theInt.y == 3 || theInt.y == 5 || theInt.y == 7) ? 1 : 0;
int int2bit2 = (theInt.y == 2 || theInt.y == 3 || theInt.y == 6 || theInt.y == 7) ? 1 : 0;
int int2bit3 = (theInt.y >= 4) ? 1 : 0;
float4 int2bit1Bounds;
float4 int2bit2Bounds;
float4 int2bit3Bounds;
int1bit1Bounds.x = float(67); //minX
int1bit1Bounds.y = float(100); //maxX
int1bit1Bounds.z = float(0); //minY
int1bit1Bounds.w = float(25); //maxY
int1bit2Bounds.x = float(34);
int1bit2Bounds.y = float(66);
int1bit2Bounds.z = float(0);
int1bit2Bounds.w = float(25);
int1bit3Bounds.x = float(0);
int1bit3Bounds.y = float(33);
int1bit3Bounds.z = float(0);
int1bit3Bounds.w = float(25);
int2bit1Bounds.x = float(67); //minX
int2bit1Bounds.y = float(100); //maxX
int2bit1Bounds.z = float(26); //minY
int2bit1Bounds.w = float(50); //maxY
int2bit2Bounds.x = float(34);
int2bit2Bounds.y = float(66);
int2bit2Bounds.z = float(26);
int2bit2Bounds.w = float(50);
int2bit3Bounds.x = float(0);
int2bit3Bounds.y = float(33);
int2bit3Bounds.z = float(26);
int2bit3Bounds.w = float(50);
// 1's place
if(
((int1bit1 > 0)&& x >= int1bit1Bounds.x && y <= int1bit1Bounds.w)||
((int1bit2 > 0) && x >= int1bit2Bounds.x && x <= int1bit2Bounds.y && y >= int1bit2Bounds.z && y <= int1bit2Bounds.w) ||
((int1bit3 > 0) && x >= int1bit3Bounds.x && x <= int1bit3Bounds.y && y >= int1bit3Bounds.z && y <= int1bit3Bounds.w) ||
((int2bit1 > 0) && x >= int2bit1Bounds.x && x <= int2bit1Bounds.y && y >= int2bit1Bounds.z && y <= int2bit1Bounds.w)||
((int2bit2 > 0) && x >= int2bit2Bounds.x && x <= int2bit2Bounds.y && y >= int2bit2Bounds.z && y <= int2bit2Bounds.w) ||
((int2bit3 > 0) && x >= int2bit3Bounds.x && x <= int2bit3Bounds.y && y >= int2bit3Bounds.z && y <= int2bit3Bounds.w)
)
{
dst.r = float(0);
dst.g = float(0);
dst.b = float(0);
}else{
dst.r = float(0.5);
dst.g = float(0.5);
dst.b = float(0.5);
}
dst.a = sampleNearest(src, outCoord()).a;
}
}