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

shader u_float (output vector cout = 0,
		output vector mcout = 0)
{
    float ufa [3];
    float fraytype = 1.0/raytype("camera");
    
    ufa[0] = 1.2 * fraytype;
    ufa[1] = 1.4 * fraytype;
    ufa[2] = 1.6 * fraytype;
    
    int zlen = int(P[0]);
    zlen = arraylength(ufa);
    //printf("array len =%d", zlen);
    cout = vector(u/zlen, u-v*ufa[2], v/zlen);
    
    vector mcout_ = cout;
    
    if (int(P[0]*P[0]*P[1]*32)%2) {    
    
        float mufa [4];
        
        mufa[0] = 5.6;
        mufa[1] = 3.4;
        mufa[2] = 7.3;
        mufa[3] = 9.9;
        
        zlen = arraylength(mufa);
        
        mcout_ = vector((v-u)/zlen, zlen*P[0], u/zlen);
    }
    
    mcout = mcout_;
}
