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

shader
test_varying_index_float (output color Cout = color(0,0,0))
{
    // Test array referencing with varying index
    float rarray[3] = { 0.1, 0.2, 0.3 };
    float garray[3] = { 0.2, 0.4, 0.6 };
    float barray[3] = { 0.3, 0.5, 0.8 };
    
    //int varyingIndex = int(clamp(P[0]*3, 0, 2));
    int varyingIndex = int(P[0]*256)%3;
    rarray[varyingIndex] = 0.0;
    // test handling of int->float implicit conversion
    garray[varyingIndex] = 0;
    barray[varyingIndex] = 0.0;
    
    Cout = color(rarray[0]+rarray[1]+rarray[2],garray[0]+garray[1]+garray[2],barray[0]+barray[1]+barray[2]);
}
