import { ShaderHelper } from '../material/shader/helper.js';
import '../material/lambert.js';
import '../material/blinn.js';
import '../material/unlit.js';
import '../material/particle.js';
import '@zephyr3d/device';
import '../values.js';
import '@zephyr3d/base';
import '../material/meshmaterial.js';
import '../material/grassmaterial.js';
import '../material/terrain-cm.js';
import '../material/pbrmr.js';
import '../material/pbrsg.js';
import '../material/pbrblueprint.js';
import '../material/sprite.js';
import '../material/sprite_std.js';
import '../utility/blueprint/material/texture.js';

function computeShadowBiasCSM(scope, NdotL, split) {
    const pb = scope.$builder;
    const depthBiasParam = ShaderHelper.getDepthBiasValues(scope);
    const splitFlags = pb.vec4(pb.float(pb.equal(split, 0)), pb.float(pb.equal(split, 1)), pb.float(pb.equal(split, 2)), pb.float(pb.equal(split, 3)));
    const depthBiasScale = pb.dot(ShaderHelper.getDepthBiasScales(scope), splitFlags);
    return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL)), depthBiasScale), pb.vec2(1, 1));
}
function computeShadowBias(lightType, scope, z, NdotL, linear) {
    const pb = scope.$builder;
    const depthBiasParam = ShaderHelper.getDepthBiasValues(scope);
    if (lightType) {
        return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL))), pb.vec2(1, 1));
    } else {
        const nearFar = ShaderHelper.getShadowCameraParams(scope).xy;
        const linearDepth = linear ? z : ShaderHelper.nonLinearDepthToLinearNormalized(scope, z, nearFar);
        const biasScaleFactor = pb.mix(1, depthBiasParam.w, linearDepth);
        return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL)), biasScaleFactor), pb.vec2(1, 1));
    }
}

export { computeShadowBias, computeShadowBiasCSM };
//# sourceMappingURL=shader.js.map
