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

shader distance_v_vector_u_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(u+v, -u-v, u+v);
    vector b = vector(1.0, 1.0, 1.0);
    
    ddistance = distance(a,b);
    dxdistance = Dx(ddistance);
    dydistance = Dy(ddistance);
    
    float mddistance_= 0.0;
    float mdxdistance_ = 0.0;
    float mdydistance_ = 0.0;

    if (int(P[0]*32)%2) {
        mddistance_ = distance(a,b+vector(0.1,0.1,0.2));
        mdxdistance_ = Dx(mddistance_);
        mdydistance_ = Dy(mddistance_);
    }

    mddistance = mddistance_;
    mdxdistance = mdxdistance_;
    mdydistance = mdydistance_;
}
