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

shader v_vector (output vector cout = 0,
		output vector mcout = 0)
{
    vector vfva [3];
    
    vfva[0] = vector(1.2 * P[0], 1.3 * P[1], 1.1*P[0]);
    vfva[1] = vector(1.4 * P[0], 1.1 * P[2], 2.3*P[1]);
    vfva[2] = vector(1.6 * P[0], 2.3 * P[2], 1.8*P[2]);
    
    int zlen = int(P[0]);
    zlen = arraylength(vfva);
    
    cout = vector(u/zlen, u-v, v/zlen);
    
    vector mcout_ = cout;
    
    if (int(P[0]*P[0]*P[1]*32)%2) {    
        vector mvfa [4];
        
        mvfa[0] = vector(8.9*P[0], 5.6*P[1], 2.3*P[1]);
        mvfa[1] = vector(1.9*P[1], 5.4*P[2], 1.7*P[0]);
        mvfa[2] = vector(2.1*P[0], 9.9*P[2], 2.3*P[0]);
        mvfa[3] = vector(0.5*P[0], 0.6*P[1], 0.7*P[2]);
        
        zlen = arraylength(mvfa);
        
        mcout_ = vector(v-u/zlen, u*v, P[0]/zlen);
    }
    
    mcout = mcout_;
}
