import { applyMaterialMixins, MeshMaterial } from './meshmaterial.js';
import { mixinAlbedoColor } from './mixins/albedocolor.js';
import { mixinVertexColor } from './mixins/vertexcolor.js';
import { ShaderHelper } from './shader/helper.js';

/**
 * Unlit material
 * @public
 */ class UnlitMaterial extends applyMaterialMixins(MeshMaterial, mixinVertexColor, mixinAlbedoColor) {
    static FEATURE_VERTEX_COLOR = 'um_vertexcolor';
    constructor(){
        super();
    }
    clone() {
        const other = new UnlitMaterial();
        other.copyFrom(this);
        return other;
    }
    vertexShader(scope) {
        super.vertexShader(scope);
        const pb = scope.$builder;
        scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);
        scope.$outputs.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;
        ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1)));
    }
    fragmentShader(scope) {
        super.fragmentShader(scope);
        if (this.needFragmentColor()) {
            let color = this.calculateAlbedoColor(scope);
            if (this.vertexColor) {
                color = scope.$builder.mul(color, this.getVertexColor(scope));
            }
            this.outputFragmentColor(scope, scope.$inputs.worldPos, color);
        } else {
            this.outputFragmentColor(scope, scope.$inputs.worldPos, null);
        }
    }
}

export { UnlitMaterial };
//# sourceMappingURL=unlit.js.map
