// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader
test (float angle = 10, float scale = 20,
      output color Cout = 0)
{
   // setup some coordinates
   float theta = radians(angle);
   float s = mod(u,0.25) - 0.125;
   float t = mod(v,0.5) - 0.25;
   float ru = cos(theta) * s + sin(theta) * t;
   float rv = sin(theta) * s - cos(theta) * t;
   ru *= scale;
   rv *= scale;
   float rz = (scale * (s + t)) / M_SQRT2;
   float ttime = s*scale;

   Cout = 0;
   if (v < 0.49) {
       // float noise in 1,2,3,4 dimensions
       if (u < 0.24)
           Cout = (float) cellnoise(ru);
       else if (u > 0.26 && u < 0.49)
           Cout = (float) cellnoise(ru, rv);
       else if (u > 0.51 && u < 0.74)
           Cout = (float) cellnoise(point(ru, rv, rz));
       else if (u > 0.76)
           Cout = (float) cellnoise(point(ru, rv, rz), ttime);
   } else if (v > 0.51) {
       // color noise in 1,2,3,4 dimensions
       if (u < 0.24)
           Cout = cellnoise(ru);
       else if (u > 0.26 && u < 0.49)
           Cout = cellnoise(ru, rv);
       else if (u > 0.51 && u < 0.74)
           Cout = cellnoise(point(ru, rv, rz));
       else if (u > 0.76)
           Cout = cellnoise(point(ru, rv, rz), ttime);
   }
}
