UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

21 lines (19 loc) 2.49 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{ZEROS as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{LayerBlendMode as r}from"../output/BlendOptions.js";import{BackgroundGrid as e}from"./BackgroundGrid.glsl.js";import{BaseOpacityMode as t}from"./BaseOpacityMode.js";import{BlendLayersOutput as a}from"./BlendLayersOutput.js";import{PremultipliedAlphaSource as l}from"./PremultipliedAlphaSource.js";import{BlendModes as c}from"../util/BlendModes.glsl.js";import{Float3PassUniform as s}from"../../shaderModules/Float3PassUniform.js";import{FloatPassUniform as i}from"../../shaderModules/FloatPassUniform.js";import{glsl as u}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as p}from"../../shaderModules/Texture2DPassUniform.js";import{NoParameters as d}from"../../../../../webgl/NoParameters.js";class m extends d{constructor(){super(...arguments),this.baseOpacity=1,this.backgroundColor=o,this.fboTexture=null}}function n(o,d){const m=d.output===a.GridComposite,n=d.output===a.ColorComposite,g=d.output===a.GroupBackgroundComposite,b=d.output===a.Composite,f=d.baseOpacityMode===t.Required,y=o.fragment;f&&y.uniforms.add(new i("baseOpacity",(o=>o.baseOpacity))),m?y.include(e):n?y.uniforms.add(new s("backgroundColor",(o=>o.backgroundColor))):b&&y.uniforms.add(new p("fboColor",(o=>o.fboTexture)));const C=d.blendMode!==r.Normal,v=d.premultipliedSource===l.On,j=!C&&!v&&(b&&!f||g);y.include(c,d),y.code.add(u` vec4 getBackground(vec2 uv) { return ${f?u`baseOpacity *`:""} ${g?u`vec4(0.0, 0.0, 0.0, 0.0)`:n?u`vec4(backgroundColor, 1.0)`:m?u`vec4(gridColor(uv), 1.0)`:u`texelFetch(fboColor, ivec2(gl_FragCoord.xy), 0)`}; } vec4 blendLayers(vec2 bgUV, vec4 colorLayer, float opacity) { ${C?u` vec3 cl = colorLayer.a == 0.0 ? colorLayer.rgb : colorLayer.rgb / colorLayer.a; vec4 bgColor = getBackground(bgUV); vec3 cb = bgColor.a == 0.0 ? bgColor.rgb : bgColor.rgb / bgColor.a; return applyBlendMode(clamp(cl, vec3(0.0), vec3(1.0)), colorLayer.a * opacity, cb, bgColor.a);`:u` float composeAlpha = colorLayer.a * opacity; ${j?u`return colorLayer * opacity;`:u` vec4 bgColor = getBackground(bgUV); return bgColor * (1.0 - composeAlpha) + colorLayer * opacity;`}`} }`)}export{n as TileBackground,m as TileBackgroundPassParameters};