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

shader distance_u_vector_u_vector_v_vector (
    output color ddistance = 0,
    output color dxdistance = 0,
    output color dydistance = 0,
                                
    output color mddistance = 0,
    output color mdxdistance = 0,
    output color mdydistance = 0)
{
    vector a = vector(0.1, 0.1, 0.7);
    vector b = vector(0.4, 0.9, -0.7);
    vector c = vector(u, v-u, u);
    
    ddistance = distance(a,b,c);
    dxdistance = Dx(ddistance);
    dydistance = Dy(ddistance);
    
    float mddistance_ = 0.0;
    float mdxdistance_ = 0.0;
    float mdydistance_ = 0.0;
    
    if (int(P[0]*32)%2) {
        c = vector(u, v, v-u);
        mddistance_ = distance(a,b+vector(u,0.2,0.3), c);
        mdxdistance_ = Dx(mddistance_);
        mdydistance_ = Dy(mddistance_);
    }
    
    mddistance = mddistance_;
    mdxdistance = mdxdistance_;
    mdydistance = mdydistance_;
}
