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


shader
checkerboard
    [[ string description = "Procedural checkerboard" ]]
(
    float s = u
        [[  string description = "s coordinate for the lookup",
            float UImin = 0, float UIsoftmax = 1 ]],
    float t = v
        [[  string description = "t coordinate for the lookup",
            float UImin = 0, float UIsoftmax = 1 ]],
    float scale_s = 4
        [[  string description = "scale factor for s coordinate" ]],
    float scale_t = 4
        [[  string description = "scale factor for t coordinate" ]],
    color Ca = color(1, 1, 1)
        [[  string description = "color of even squares" ]],
    color Cb = color(0, 0, 0)
        [[  string description = "color of odd squares" ]],
    output color Cout = 0
        [[  string description = "Output color",
            float UImin = 0, float UImax = 1 ]]
  )
{
// TODO: anti-alias
    float cs = fmod(s * scale_s, 2);
    float ct = fmod(t * scale_t, 2);
    if ((int(cs) ^ int(ct)) == 0)
       Cout = Ca;
    else
       Cout = Cb;
}
