/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{ZEROS as i,freeze as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{glLayout as l}from"../../support/buffer/glUtil.js";import{newLayout as n}from"../../support/buffer/InterleavedLayout.js";import{VertexNormalPassParameters as a,VertexNormalDrawParameters as c}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{ReloadableShader as h}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as u}from"../core/shaderTechnique/ShaderTechnique.js";import{olidEnabled as m}from"../effects/geometry/olidUtils.js";import{depthWrite as p,blending as d,depthTest as f}from"../lib/OrderIndependentTransparency.js";import{stencilToolMaskBase as g,stencilBaseAllZeros as v,stencilWriteMaskOn as b}from"../lib/StencilUtils.js";import{getRenderInstanceDataLayout as S}from"../lib/lodRendering/RenderInstanceData.js";import{advancedMRRFactors as y}from"../materials/pbrUtils.js";import{polygonOffset as j}from"../materials/PolygonOffset.js";import{D as P}from"../../../../chunks/DefaultMaterial.glsl.js";import{makePipelineState as T,cullingParams as x,defaultColorWrite as C}from"../../../webgl/renderState.js";import{alphaCutoff as O}from"../../../../webscene/support/AlphaCutoff.js";class D extends a{constructor(){super(...arguments),this.isSchematic=!1,this.usePBR=!1,this.mrrFactors=y,this.hasVertexColors=!1,this.hasSymbolColors=!1,this.doubleSided=!1,this.doubleSidedType="normal",this.cullFace=2,this.instanced=!1,this.instancedFeatureAttribute=!1,this.instancedColor=!1,this.instanceColorEncodesAlphaIgnore=!1,this.emissiveStrengthFromSymbol=0,this.emissiveStrengthKHR=1,this.emissiveSource=1,this.emissiveBaseColor=i,this.instancedDoublePrecision=!1,this.normalType=0,this.receiveShadows=!0,this.receiveAmbientOcclusion=!0,this.castShadows=!0,this.ambient=s(.2,.2,.2),this.diffuse=s(.8,.8,.8),this.externalColor=o(1,1,1,1),this.colorMixMode="multiply",this.opacity=1,this.layerOpacity=1,this.origin=r(),this.hasSlicePlane=!1,this.offsetTransparentBackfaces=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.modelTransformation=null,this.drivenOpacity=!1,this.writeDepth=!0,this.customDepthTest=0,this.textureAlphaMode=0,this.textureAlphaCutoff=O,this.textureAlphaPremultiplied=!1,this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class V extends c{constructor(){super(...arguments),this.origin=r(),this.slicePlaneLocalOrigin=this.origin}}let w=class extends u{constructor(e,t){let i=l(z(t));t.instanced&&t.instancedDoublePrecision&&(i=i.concat(l(S(t)))),super(e,t,i),this.shader=new h(P,()=>import("./DefaultMaterial.glsl.js")),this.ignoreUnused=!0}_makePipeline(e,t){const{output:i,transparent:s,cullFace:r,customDepthTest:o,hasOccludees:l}=e;return T({blending:s?d(i,!1,e.emissionDimmingPass):null,culling:M(e)?x(r):null,depthTest:f(i,A(o)),depthWrite:p(e),colorWrite:C,stencilWrite:l?b:null,stencilTest:l?t?g:v:null,polygonOffset:j(e)})}initializePipeline(e){return this._occludeePipelineState=this._makePipeline(e,!0),this._makePipeline(e,!1)}getPipeline(e,t,i){return i?this._occludeePipelineState:super.getPipeline(e,t,i)}};function A(e){switch(e){case 1:return 515;case 0:case 3:return 513;case 2:return 516}}function M(e){return 0!==e.cullFace||!e.hasSlicePlane&&(!e.transparent&&!e.doubleSidedMode)}function z(e){const t=n().vec3f("position");return 1===e.normalType?t.vec2i16("normalCompressed",{glNormalized:!0}):t.vec3f("normal"),e.hasVertexTangents&&t.vec4f("tangent"),e.hasTextures&&t.vec2f16("uv0"),e.hasVertexColors&&t.vec4u8("color",{glNormalized:!0}),e.hasSymbolColors&&t.vec4u8("symbolColor"),!e.instanced&&m()&&t.vec4u8("olidColor"),t}w=e([t("esri.views.3d.webgl-engine.shaders.DefaultMaterialTechnique")],w);export{V as DefaultMaterialDrawParameters,D as DefaultMaterialPassParameters,w as DefaultMaterialTechnique,z as getLayout,M as isCullingRequired};
