@arcgis/core 4.31.0-next.20240606 → 4.31.0-next.20240607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{24a02d266749a77c8ae1.js → 7866b86ebe02adf5e874.js} +17 -17
- package/chunks/ColorMaterial.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +1 -1
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/HUDMaterial.glsl.js +32 -32
- package/chunks/ImageMaterial.glsl.js +1 -1
- package/chunks/LineMarker.glsl.js +1 -1
- package/chunks/NativeLine.glsl.js +1 -1
- package/chunks/OITCompositing.glsl.js +12 -9
- package/chunks/Pattern.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +1 -1
- package/chunks/ShadedColorMaterial.glsl.js +1 -1
- package/chunks/WaterSurface.glsl.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileAgent.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as p,sync as u}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{TransparencyMode as O}from"../../terrain/TerrainRenderer.js";import{DepthFormat as y,ColorFormat as N}from"../../webgl/formats.js";import{FBOCache as D,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as H}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as X}from"./depthRange.js";import{depthRangeFromScene as Y}from"./depthRangeUtils.js";import{RenderOccludedFlag as z}from"./Material.js";import{OffscreenRendering as J}from"./OffscreenRendering.js";import{RenderContext as K,defaultRenderOccludedMask as Z}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as $,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as pe}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ue}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as be,PixelType as Ee,ClearBufferBit as Ae}from"../../../webgl/enums.js";class Pe{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=O.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new D(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._offscreen=new J(this.fboCache,this._compositingHelper),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(L.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._nodes=new F(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new x,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),p),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):R;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=H}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._offscreen.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(L.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.viewshedShadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),u)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&f(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;const a=$(e);let n=!1;a.forEach(((r,s)=>{if(t.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&r.adds.length>0){const e=new pe({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(r),0===i.numGeometries&&(n=!0)),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(L.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(L.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ee.Default,s=G.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),p=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const u=i.initializeFrame(a,this._backgroundColor,r);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(L.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===O.Semitransparent||this._terrainTransparency===O.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(L.Color,...Ie);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let T=this._renderNormals();if(this._pluginInput.set("normals",T),T){let e=null;this._needsDepth&&(e=T.getAttachment(Te),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(e),T=null}else this._renderAllGeometryDepth();this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=L.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture;const b=this.plugins.produces(L.Color,...we);b&&this._renderOpaqueGeometry(),this._offscreen.updateColor((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",this._offscreen.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bindFbo(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(Re.Geometry):this._renderTransparentMaterial()),this._offscreen.updateColor((e=>this._renderNodes(C.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",this._offscreen.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const E=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=c?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(v.Occluded):i.compositeToHUDVisibility(this._bindParameters,A.getTexture()),this._renderHUD(v.Occluded,i.color))),this._setTerrainCulling(!1),A&&(i.compositeToFramebuffer(this._bindParameters,A.getTexture(),ue.PremultipliedAlpha,1),A.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(Re.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(v.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),this._renderLaserlines(),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._offscreen.updateColor((e=>this._renderNodes(C.COMPOSITE,e)));const P=this._nodes.produces("aa-color"),R=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),I=this._pluginInput.get("composite-color"),y=R?M:this.fboCache.acquire(I.fbo.width,I.fbo.height,"aa-color"),N=P?this._renderNodes(w.ANTIALIASING,y):this._blitToDefault(I,y,!1);this._pluginInput.set(w.ANTIALIASING,N),this._renderHUD(v.NotOccluded,N);const D=this._renderNodes(w.HIGHLIGHTS,N);let x=this._renderNodes(w.MAGNIFIER,D);return l&&s===G.ON&&r===ee.Default&&!_&&(x=this._blitToDefault(x)),_?(x.attachDepth(i.depth),this._blitToDefault(this._renderNodes(C.FINAL,x)),x.detachDepth()):this._pluginInput.set(C.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:E}}_prepareShaders(e,t){this._renderContext.output=L.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT,ie.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oid");return t.acquireDepth(y.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(L.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=v.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){if(!this._bindParameters.mainDepth)return;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"linear-depth");this._rctx.bindFramebuffer(i.fbo),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,this._bindParameters.mainDepth),i.fbo?.readPixels(e[0],e[1],e[2],e[3],be.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,be.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"edges"),n=()=>t.render(this._bindParameters,e),h=this._bindParameters.multipassGeometry.depth;this._offscreen.renderToTargets(n,a,h??i,Ce),this._offscreen.compositeToFramebuffer(this._bindParameters,a.getTexture(),ue.Alpha,1),a.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(L.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(L.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(L.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(L.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this._renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(L.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:t,height:r}=this._offscreen,s=this.fboCache.acquire(t,r,"depth");s.attachDepth(e),e.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:e,height:t}=this._offscreen,r=this.fboCache.acquire(e,t,"depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=L.Depth;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"terrain depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"geometry depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(L.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=i.obtainDepthTexture(),i.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=Y(e,this._plugins.plugins,this._stage.layers);return X(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(L.Normal)),[0,0,0,0],N.RGBA,y.DEPTH_STENCIL_TEXTURE),s=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color");return r.retain(t+s-1),this.performanceInfo.advance(fe.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();const t=this._nodes.render("ssao",this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...we,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...we)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==L.Color)return void t();const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"transparent terrain");return this._offscreen.renderToTargets(t,a,i,[0,0,0,0]),a}_renderHUDVisibility(){this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS)),this._bindParameters.multipassGeometry.depth),this._offscreen.bindFbo(),this.performanceInfo.advance(fe.HUD_VISIBILITY)):this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),{width:t,height:r,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,t,r,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS)}_renderLaserlines(){const e=this._plugins.produces(this._renderContext.output,ie.LASERLINES_CONTRAST_CONTROL);if(this._plugins.produces(this._renderContext.output,ie.LASERLINES)||e){if(this._plugins.render(this._pluginInput,ie.LASERLINES),e){const e=this._offscreen,{width:t,height:r,depth:s}=e,i=this.fboCache.acquire(t,r,"laser lines"),a=()=>this._plugins.render(this._pluginInput,ie.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,Ce),e.compositeToFramebuffer(this._bindParameters,i.getTexture(),ue.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(fe.LASER_LINES)}}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(Re.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),ue.PremultipliedAlpha),r.release()}else if(e===v.Occluded){this._renderContext.output=L.Color;const t=()=>this._renderHUDElements(e),{width:r,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,s,"hud");this._offscreen.renderToTargets(t,i,a,void 0,!0,!0),a.release()}else this._renderContext.output=L.Color,t.acquireDepth(y.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(L.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const e=()=>{this._renderAllGeometry(L.Highlight),this._rctx.clear(Ae.DEPTH_BUFFER_BIT),this._renderHUDElements(v.Both)},t=this._offscreen.renderToCachedFBO(null,"highlights",e,[0,0,0,0],N.RGBA4,y.DEPTH_STENCIL_TEXTURE);return t.detachDepth(),t}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=L.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=v.Both){const r=e===Re.HUD,s=r?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=L.Color,this._bindParameters.transparencyPassType=de.ColorAlpha;const n=this._offscreen.renderOITPass(i,de.ColorAlpha,r);this._bindParameters.transparencyPassType=de.FrontFace;const h=this._offscreen.renderOITPass(i,de.FrontFace,r);return this._offscreen.compositeOIT(this._bindParameters,n,h,s),s?.detachDepth(),h.release(),n.release(),this._bindParameters.transparencyPassType=de.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;t.queryRenderOccludedState(z.OccludeAndTransparentStencil)&&(e|=z.OccludeAndTransparentStencil,Oe.push(t))}));const t=this._offscreen,r=(r,s,i,a,n)=>{if(!(e&s))return;const{width:h,height:o,depth:d}=t,l=this.fboCache.acquire(h,o,"tmp color");t.renderToTargets(i,l,d,[0,0,0,0],a,n),t.compositeToFramebuffer(this._bindParameters,l.getTexture(),ue.PremultipliedAlpha,r),l.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(U(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==Oe.length&&(s(ie.OCCLUDER_MATERIAL,Oe),r(.5,z.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,Oe)),!1,!1));const i=Oe.length>0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;const r=t.queryRenderOccludedState(z.OccludeAndTransparent),s=t.queryRenderOccludedState(z.Transparent),i=t.queryRenderOccludedState(z.Opaque);(r||s||i)&&(e|=r?z.OccludeAndTransparent:s?z.Transparent:z.Opaque,Oe.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>z.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,Oe),s(ie.TRANSPARENT_MATERIAL,Oe),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Oe),this._renderContext.renderOccludedMask=Z};this._renderContext.output=L.Color,r(.5,z.OccludeAndTransparent,(()=>n(z.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,z.Transparent,(()=>n(z.Transparent)),!0,Q.OutlineVisualElementMask),r(1,z.Opaque,(()=>n(z.Opaque)),!0,Q.OutlineVisualElementMask),(i||Oe.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),Oe.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._offscreen.bindFbo(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._plugins.produces(this._renderContext.output,ie.VIEWSHED)&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this.performanceInfo.advance(fe.VIEWSHED))}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitToDefault(e,t=M,r=!0){this._blit||(this._blit=new V(this._techniques));const s=this._blit.render(this._rctx,e,t,this._bindParameters,this._requestRender);return this._pluginInput.set(e.name,s),r&&e.release(),s}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(Ne,this._bindParameters.camera.viewMatrix),g(ye,this._bindParameters.camera.projectionMatrix),T(De,Ne,ye),T(De,this._renderContext.lastFrameCamera.viewMatrix,De),T(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){}}var Re,Se;e([m({readOnly:!0})],Pe.prototype,"fullResolutionAtmosphere",null),e([m()],Pe.prototype,"_edgeView",void 0),e([m()],Pe.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Re||(Re={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility",e[e.ViewshedShadowMap=4]="ViewshedShadowMap"}(Se||(Se={}));const Ce=[0,0,0,0],we=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Ie=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],Oe=new o,ye=E(),Ne=E(),De=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se as FramebufferId,Pe as Renderer};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as p,sync as u}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{TransparencyMode as O}from"../../terrain/TerrainRenderer.js";import{DepthFormat as N,ColorFormat as y}from"../../webgl/formats.js";import{FBOCache as D,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as H}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as X}from"./depthRange.js";import{depthRangeFromScene as Y}from"./depthRangeUtils.js";import{RenderOccludedFlag as z}from"./Material.js";import{OffscreenRendering as J}from"./OffscreenRendering.js";import{RenderContext as K,defaultRenderOccludedMask as Z}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as $,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as pe}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ue}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as be,PixelType as Ee,ClearBufferBit as Ae}from"../../../webgl/enums.js";class Re{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=R(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=O.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new D(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._offscreen=new J(this.fboCache,this._compositingHelper),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(L.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._nodes=new F(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new x,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),p),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):P;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=H}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._offscreen.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(L.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.viewshedShadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),u)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&f(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;const a=$(e);let n=!1;a.forEach(((r,s)=>{if(t.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&r.adds.length>0){const e=new pe({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(r),0===i.numGeometries&&(n=!0)),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(L.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(L.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ee.Default,s=G.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),p=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const u=i.initializeFrame(a,this._backgroundColor,r);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(L.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===O.Semitransparent||this._terrainTransparency===O.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(L.Color,...Ie);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let T=this._renderNormals();if(this._pluginInput.set("normals",T),T){let e=null;this._needsDepth&&(e=T.getAttachment(Te),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(e),T=null}else this._renderAllGeometryDepth();this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=L.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture;const b=this.plugins.produces(L.Color,...we);b&&this._renderOpaqueGeometry(),this._offscreen.updateColor((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",this._offscreen.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bindFbo(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(Pe.Geometry):this._renderTransparentMaterial()),this._offscreen.updateColor((e=>this._renderNodes(C.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",this._offscreen.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const E=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=c?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(v.Occluded):i.compositeToHUDVisibility(this._bindParameters,A.getTexture()),this._renderHUD(v.Occluded,i.color))),this._setTerrainCulling(!1),A&&(i.compositeToFramebuffer(this._bindParameters,A.getTexture(),ue.PremultipliedAlpha,1),A.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(Pe.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(v.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),this._renderLaserlines(),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._offscreen.updateColor((e=>this._renderNodes(C.COMPOSITE,e)));const R=this._nodes.produces("aa-color"),P=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),I=this._pluginInput.get("composite-color"),N=P?M:this.fboCache.acquire(I.fbo.width,I.fbo.height,"aa-color"),y=R?this._renderNodes(w.ANTIALIASING,N):this._blitToDefault(I,N,!1);this._pluginInput.set(w.ANTIALIASING,y),this._renderHUD(v.NotOccluded,y);const D=this._renderNodes(w.HIGHLIGHTS,y);let x=this._renderNodes(w.MAGNIFIER,D);return l&&s===G.ON&&r===ee.Default&&!_&&(x=this._blitToDefault(x)),_?(x.attachDepth(i.depth),this._blitToDefault(this._renderNodes(C.FINAL,x)),x.detachDepth()):this._pluginInput.set(C.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:E}}_prepareShaders(e,t){this._renderContext.output=L.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT,ie.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oid");return t.acquireDepth(N.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(L.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=v.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){if(!this._bindParameters.mainDepth)return;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"linear-depth");this._rctx.bindFramebuffer(i.fbo),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,this._bindParameters.mainDepth),i.fbo?.readPixels(e[0],e[1],e[2],e[3],be.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,be.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"edges"),n=()=>t.render(this._bindParameters,e),h=this._bindParameters.multipassGeometry.depth;this._offscreen.renderToTargets(n,a,h??i,Ce),this._offscreen.compositeToFramebuffer(this._bindParameters,a.getTexture(),ue.Alpha,1),a.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(L.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(L.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(L.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(L.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this._renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(L.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:t,height:r}=this._offscreen,s=this.fboCache.acquire(t,r,"depth");s.attachDepth(e),e.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:e,height:t}=this._offscreen,r=this.fboCache.acquire(e,t,"depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=L.Depth;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"terrain depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"geometry depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(L.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=i.obtainDepthTexture(),i.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=Y(e,this._plugins.plugins,this._stage.layers);return X(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(L.Normal)),[0,0,0,0],y.RGBA,N.DEPTH_STENCIL_TEXTURE),s=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color");return r.retain(t+s-1),this.performanceInfo.advance(fe.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();const t=this._nodes.render("ssao",this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...we,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...we)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==L.Color)return void t();const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"transparent terrain");return this._offscreen.renderToTargets(t,a,i,[0,0,0,0]),a}_renderHUDVisibility(){this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS)),this._bindParameters.multipassGeometry.depth),this._offscreen.bindFbo(),this.performanceInfo.advance(fe.HUD_VISIBILITY)):this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),{width:t,height:r,color:s}=this._offscreen,i=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,t,r,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS)}_renderLaserlines(){const e=this._plugins.produces(this._renderContext.output,ie.LASERLINES_CONTRAST_CONTROL);if(this._plugins.produces(this._renderContext.output,ie.LASERLINES)||e){if(this._plugins.render(this._pluginInput,ie.LASERLINES),e){const e=this._offscreen,{width:t,height:r,depth:s}=e,i=this.fboCache.acquire(t,r,"laser lines"),a=()=>this._plugins.render(this._pluginInput,ie.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,Ce),e.compositeToFramebuffer(this._bindParameters,i.getTexture(),ue.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(fe.LASER_LINES)}}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(Pe.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),ue.PremultipliedAlpha),r.release()}else if(e===v.Occluded){this._renderContext.output=L.Color;const t=()=>this._renderHUDElements(e),{width:r,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,r,s,"hud");this._offscreen.renderToTargets(t,i,a,void 0,!0,!0),a.release()}else this._renderContext.output=L.Color,t.acquireDepth(N.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(L.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const e=()=>{this._renderAllGeometry(L.Highlight),this._rctx.clear(Ae.DEPTH_BUFFER_BIT),this._renderHUDElements(v.Both)},t=this._offscreen.renderToCachedFBO(null,"highlights",e,[0,0,0,0],y.RGBA4,N.DEPTH_STENCIL_TEXTURE);return t.detachDepth(),t}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=L.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=v.Both){const r=e===Pe.HUD,s=r?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),a=this._renderContext.output;return this._renderContext.output=L.Color,this._offscreen.renderOIT(this._bindParameters,i,s),this._renderContext.output=a,s}_renderOccluded(){let e=0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;t.queryRenderOccludedState(z.OccludeAndTransparentStencil)&&(e|=z.OccludeAndTransparentStencil,Oe.push(t))}));const t=this._offscreen,r=(r,s,i,a,n)=>{if(!(e&s))return;const{width:h,height:o,depth:d}=t,l=this.fboCache.acquire(h,o,"tmp color");t.renderToTargets(i,l,d,[0,0,0,0],a,n),t.compositeToFramebuffer(this._bindParameters,l.getTexture(),ue.PremultipliedAlpha,r),l.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(U(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==Oe.length&&(s(ie.OCCLUDER_MATERIAL,Oe),r(.5,z.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,Oe)),!1,!1));const i=Oe.length>0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;const r=t.queryRenderOccludedState(z.OccludeAndTransparent),s=t.queryRenderOccludedState(z.Transparent),i=t.queryRenderOccludedState(z.Opaque);(r||s||i)&&(e|=r?z.OccludeAndTransparent:s?z.Transparent:z.Opaque,Oe.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>z.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,Oe),s(ie.TRANSPARENT_MATERIAL,Oe),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Oe),this._renderContext.renderOccludedMask=Z};this._renderContext.output=L.Color,r(.5,z.OccludeAndTransparent,(()=>n(z.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,z.Transparent,(()=>n(z.Transparent)),!0,Q.OutlineVisualElementMask),r(1,z.Opaque,(()=>n(z.Opaque)),!0,Q.OutlineVisualElementMask),(i||Oe.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),Oe.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._offscreen.bindFbo(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._plugins.produces(this._renderContext.output,ie.VIEWSHED)&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this.performanceInfo.advance(fe.VIEWSHED))}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitToDefault(e,t=M,r=!0){this._blit||(this._blit=new V(this._techniques));const s=this._blit.render(this._rctx,e,t,this._bindParameters,this._requestRender);return this._pluginInput.set(e.name,s),r&&e.release(),s}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(ye,this._bindParameters.camera.viewMatrix),g(Ne,this._bindParameters.camera.projectionMatrix),T(De,ye,Ne),T(De,this._renderContext.lastFrameCamera.viewMatrix,De),T(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){}}var Pe,Se;e([m({readOnly:!0})],Re.prototype,"fullResolutionAtmosphere",null),e([m()],Re.prototype,"_edgeView",void 0),e([m()],Re.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Pe||(Pe={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility",e[e.ViewshedShadowMap=4]="ViewshedShadowMap"}(Se||(Se={}));const Ce=[0,0,0,0],we=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Ie=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],Oe=new o,Ne=E(),ye=E(),De=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se as FramebufferId,Re as Renderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromArray as e,fromValues as t,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as s}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as a}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as n,VertexNormalDrawParameters as c}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{
|
|
5
|
+
import{fromArray as e,fromValues as t,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as s}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as a}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as n,VertexNormalDrawParameters as c}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{alphaCutoff as h}from"../core/shaderLibrary/util/AlphaCutoff.js";import{ReloadableShaderModule as u}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as m}from"../core/shaderTechnique/ShaderTechnique.js";import{CullFaceOptions as p,DepthTestFunction as d,AlphaDiscardMode as f}from"../lib/basicInterfaces.js";import{Default3D as b}from"../lib/DefaultVertexAttributeLocations.js";import{RenderOccludedFlag as g}from"../lib/Material.js";import{blendingDefault as y,oitBlending as x,oitDepthTest as T,oitDrawBuffers as j,getOITPolygonOffset as P}from"../lib/OrderIndependentTransparency.js";import{Program as S}from"../lib/Program.js";import{stencilWriteMaskOn as O,stencilToolMaskBaseParams as v,stencilBaseAllZerosParams as C}from"../lib/StencilUtils.js";import{TransparencyPassType as L}from"../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as M}from"../materials/pbrUtils.js";import{D as w}from"../../../../chunks/DefaultMaterial.glsl.js";import{SpecialDrawBuffers as A,CompareFunction as D}from"../../../webgl/enums.js";import{makePipelineState as N,cullingParams as F,defaultDepthWriteParams as _,defaultColorWriteParams as k}from"../../../webgl/renderState.js";class q extends n{constructor(){super(...arguments),this.isSchematic=!1,this.usePBR=!1,this.mrrFactors=e(M),this.hasVertexColors=!1,this.hasSymbolColors=!1,this.doubleSided=!1,this.doubleSidedType="normal",this.cullFace=p.Back,this.isInstanced=!1,this.hasInstancedColor=!1,this.emissiveFactor=t(0,0,0),this.instancedDoublePrecision=!1,this.normalType=a.Attribute,this.receiveShadows=!0,this.receiveAmbientOcclusion=!0,this.castShadows=!0,this.shadowMappingEnabled=!1,this.ambient=t(.2,.2,.2),this.diffuse=t(.8,.8,.8),this.externalColor=r(1,1,1,1),this.colorMixMode="multiply",this.opacity=1,this.layerOpacity=1,this.origin=i(),this.hasSlicePlane=!1,this.hasSliceHighlight=!0,this.offsetTransparentBackfaces=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.modelTransformation=null,this.transparent=!1,this.writeDepth=!0,this.customDepthTest=d.Less,this.textureAlphaMode=f.Blend,this.textureAlphaCutoff=h,this.textureAlphaPremultiplied=!1,this.hasOccludees=!1,this.renderOccluded=g.Occlude,this.isDecoration=!1}}class z extends c{constructor(){super(...arguments),this.origin=i(),this.slicePlaneLocalOrigin=this.origin}}class E extends m{initializeConfiguration(e,t){t.spherical=e.viewingMode===s.Global,t.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result,t.textureCoordinateType=t.hasColorTexture||t.hasMetallicRoughnessTexture||t.hasEmissionTexture||t.hasOcclusionTexture||t.hasNormalTexture?l.Default:l.None,t.objectAndLayerIdColorInstanced=t.instanced}initializeProgram(e){return this._initializeProgram(e,E.shader)}_initializeProgram(e,t){return new S(e.rctx,t.get().build(this.configuration),b)}_makePipeline(e,t){const i=this.configuration,r=e===L.NONE,s=e===L.FrontFace;return N({blending:i.output===o.Color&&i.transparent?r?y:x(e):null,culling:R(i)?F(i.cullFace):null,depthTest:{func:T(e,I(i.customDepthTest))},depthWrite:(r||s)&&i.writeDepth?_:null,drawBuffers:i.output===o.Depth?{buffers:[A.NONE]}:j(e),colorWrite:k,stencilWrite:i.hasOccludees?O:null,stencilTest:i.hasOccludees?t?v:C:null,polygonOffset:r||s?null:P(i.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._makePipeline(this.configuration.transparencyPassType,!0),this._makePipeline(this.configuration.transparencyPassType,!1)}getPipeline(e){return e?this._occludeePipelineState:super.getPipeline()}}function I(e){return e===d.Lequal?D.LEQUAL:D.LESS}function R(e){return e.cullFace!==p.None||!e.hasSlicePlane&&(!e.transparent&&!e.doubleSidedMode)}E.shader=new u(w,(()=>import("./DefaultMaterial.glsl.js")));export{z as DefaultMaterialDrawParameters,q as DefaultMaterialPassParameters,E as DefaultMaterialTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";export{O as OITCompositingPassParameters,b as build}from"../../../../chunks/OITCompositing.glsl.js";
|
|
5
|
+
import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";export{O as OITCompositingPassParameters,b as build}from"../../../../chunks/OITCompositing.glsl.js";
|