/**
 * Foliage mixin
 *
 * @param BaseCls - Class to mix in
 * @returns Mixed class
 *
 * @public
 */ function mixinFoliage(BaseCls) {
    if (BaseCls.foliageMixed) {
        return BaseCls;
    }
    return class extends BaseCls {
        static foliageMixed = true;
        constructor(){
            super();
            this.cullMode = 'none';
        }
        calculateFoliageAlbedo(scope, albedoColor, texelCoord) {
            const pb = scope.$builder;
            const that = this;
            const funcNameCalcMipLevel = 'Z_CalcFoliageMipLevel';
            pb.func(funcNameCalcMipLevel, [
                pb.vec2('coord')
            ], function() {
                this.$l.dx = pb.dpdx(this.coord);
                this.$l.dy = pb.dpdy(this.coord);
                this.$l.deltaMaxSqr = pb.max(pb.dot(this.dx, this.dx), pb.dot(this.dy, this.dy));
                this.$return(pb.max(0, pb.mul(pb.log2(this.deltaMaxSqr), 0.5)));
            });
            const funcNameCalcFoliageAlbedo = 'Z_calcFoliageAlbedo';
            pb.func(funcNameCalcFoliageAlbedo, [
                pb.vec4('albedo'),
                pb.vec2('coord')
            ], function() {
                this.$l.a = pb.mul(this.albedo.a, pb.add(1, pb.mul(pb.max(0, scope[funcNameCalcMipLevel](this.coord)), 0.5)));
                if (that.alphaToCoverage) {
                    this.a = pb.add(pb.div(pb.sub(this.a, 0.4), pb.max(pb.fwidth(this.albedo.a), 0.0001)), 0.5);
                }
                this.$return(pb.vec4(this.albedo.rgb, this.a));
            });
            return pb.getGlobalScope()[funcNameCalcFoliageAlbedo](albedoColor, texelCoord);
        }
    };
}

export { mixinFoliage };
//# sourceMappingURL=foliage.js.map
