/* Cross & Squares */
surface
cross_test(float Kfb = 1, /* fake brightness */
Kd = 0.85,
srepeats = 10,
trepeats = 10,
tflip = 1, /* [0 or 1] uv/st flip */
//Cross//
centerVert = .5,
centerHor = .5,
width = .1;
color crossColor = color (.279,1,0),
//Box//
box1Color = color (0,0,1),
box2Color = color (0,0,1),
box3Color = color (0,0,1),
box4Color = color (0,0,1);
)
{
color BGcolor = color .0001,
surfcolor = .0001,
surfopacity = 1;
normal Nn = normalize(N);
float tt = 1 - t;
float left = centerVert - (.5 * width),
right = centerVert + (.5 * width),
top = centerHor - (.5 * width),
bottom = centerHor + (.5 * width),
Ka = 0.5;
if(tflip == 0)
tt = t;
// Apply repetitions
float S = mod(s * srepeats, 1);
float T = mod(tt * trepeats, 1);
if(S >= left && S <= right || T >= top && T <= bottom)//cross
surfcolor = crossColor;
if ((S <= .97 && S >= right+.03) && (T <= top-.03 && T >= .03))//box1
surfcolor = box1Color;
if ((S <= .94 && S >= right+.06) && (T <= top-.06 && T >= .06))
surfcolor = BGcolor;
if ((S <= .91 && S >= right+.09) && (T <= top-.09 && T >= .09))
surfcolor = box3Color;
if ((S <= .88 && S >= right+.12) && (T <= top-.12 && T >= .12))
surfcolor = BGcolor;
if ((S <= left-.03 && S >= .03) && (T <= top-.03 && T >= .03))//box2
surfcolor = box2Color;
if ((S <= left-.06 && S >= .06) && (T <= top-.06 && T >= .06))
surfcolor = BGcolor;
if ((S <= left-.09 && S >= .09) && (T <= top-.09 && T >= .09))
surfcolor = box4Color;
if ((S <= left-.12 && S >= .12) && (T <= top-.12 && T >= .12))
surfcolor = BGcolor;
if ((S <= left-.03 && S >= .03) && (T <= .97 && T >= bottom+.03))//box3
surfcolor = box3Color;
if ((S <= left-.06 && S >= .06) && (T <= .94 && T >= bottom+.06))
surfcolor = BGcolor;
if ((S <= left-.09 && S >= .09) && (T <= .91 && T >= bottom+.09))
surfcolor = box1Color;
if ((S <= left-.12 && S >= .12) && (T <= .88 && T >= bottom+.12))
surfcolor = BGcolor;
if ((S <= .97 && S >= right+.03) && (T <= .97 && T >= bottom+.03))//box4
surfcolor = box4Color;
if ((S <= .94 && S >= right+.06) && (T <= .94 && T >= bottom+.06))
surfcolor = BGcolor;
if ((S <= .91 && S >= right+.09) && (T <= .91 && T >= bottom+.09))
surfcolor = box2Color;
if ((S <= .88 && S >= right+.12) && (T <= .88 && T >= bottom+.12))
surfcolor = BGcolor;
// Opacity White .0001 = transparent
if (surfcolor == color .0001)
surfopacity = 0;
/* STEP 1 - set the apparent surface opacity */
Oi = Os * surfopacity;
/* STEP 2 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * Kfb * (Ka * ambient() + Kd * diffuse(Nn));
}