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

shader v_float (output vector cout = 0,
		output vector mcout = 0)
{
    float float_array [10];
    
    float_array[0] = 1.2 * P[0];
    float_array[1] = 1.4 * P[0];
    float_array[2] = 1.6 * P[0];
    
    float_array[3] = 1.5 * P[0];
    float_array[4] = 1.1 * P[0];
    float_array[5] = 1.6 * P[0];
    
    float_array[6] = 1.3 * P[0];
    float_array[7] = 1.1 * P[0];
    float_array[8] = 1.8 * P[0];
    
    float_array[9] = 2.3 * P[0];
    
    int zlen = int(P[0]);
    zlen += arraylength(float_array);
    
    cout = vector(u/zlen, u-v*float_array[4], v/zlen);
    
    vector mcout_ = cout;
    
    if (int(P[0]*P[0]*P[1]*32)%2) {    
    
        float vfa [4];
        
        vfa[0] = 5.6 * P[1];
        vfa[1] = 3.4 * P[2];
        vfa[2] = 7.3 * P[0];
        vfa[3] = 9.9 * P[0];
        
        zlen = arraylength(vfa);
        
        mcout_ = vector((v-u)/zlen, zlen*P[0], u/zlen);
    }

    mcout = mcout_;
}
