import { RenderPass } from './renderpass.js';
import { RENDER_PASS_TYPE_DEPTH } from '../values.js';
import { ShaderHelper } from '../material/shader/helper.js';

/**
 * Depth render pass
 *
 * Scene depth render pass
 *
 * @public
 */ class DepthPass extends RenderPass {
    _renderBackface;
    _encodeDepth;
    _transmission;
    /**
   * Creates an instance of DepthRenderPass
   */ constructor(){
        super(RENDER_PASS_TYPE_DEPTH);
        this._renderBackface = false;
        this._encodeDepth = false;
        this._transmission = false;
    }
    get transmission() {
        return this._transmission;
    }
    set transmission(val) {
        this._transmission = val;
    }
    get renderBackface() {
        return this._renderBackface;
    }
    set renderBackface(val) {
        this._renderBackface = !!val;
    }
    get encodeDepth() {
        return this._encodeDepth;
    }
    set encodeDepth(val) {
        this._encodeDepth = !!val;
    }
    /** @internal */ _getGlobalBindGroupHash(ctx) {
        return `${Number(this._renderBackface)}:${Number(this._encodeDepth)}:${Number(ctx.motionVectors)}`;
    }
    /** @internal */ renderItems(ctx, renderCamera, renderQueue) {
        const items = renderQueue.itemList;
        if (items) {
            ctx.drawEnvLight = false;
            ctx.env = null;
            ctx.flip = this.isAutoFlip(ctx);
            ctx.renderPassHash = this.getGlobalBindGroupHash(ctx, renderCamera);
            const bindGroup = ctx.globalBindGroupAllocator.getGlobalBindGroup(ctx);
            ctx.device.setBindGroup(0, bindGroup);
            ShaderHelper.setCameraUniforms(bindGroup, ctx, renderCamera, true);
            const reverseWinding = ctx.camera.worldMatrixDet < 0;
            const list = this._transmission ? items.transmission : items.opaque;
            for (const lit of list.lit){
                this.drawItemList(lit, ctx, reverseWinding);
            }
            for (const unlit of list.unlit){
                this.drawItemList(unlit, ctx, reverseWinding);
            }
        }
    }
}

export { DepthPass };
//# sourceMappingURL=depthpass.js.map
