UNPKG

@arcgis/core

Version:

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

54 lines (53 loc) 3.1 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{ReadDepth as e}from"./output/ReadDepth.glsl.js";import{CameraSpace as o}from"./util/CameraSpace.glsl.js";import{Float3PassUniform as l}from"../shaderModules/Float3PassUniform.js";import{FloatPassUniform as t}from"../shaderModules/FloatPassUniform.js";import{glsl as r}from"../shaderModules/glsl.js";import{Texture2DBindUniform as a}from"../shaderModules/Texture2DBindUniform.js";import{Texture2DPassUniform as n}from"../shaderModules/Texture2DPassUniform.js";function i(i,p){const d=i.fragment;d.include(e),i.include(o),d.uniforms.add(new t("globalAlpha",(e=>e.globalAlpha)),new l("glowColor",(e=>e.glowColor)),new t("glowWidth",((e,o)=>e.glowWidth*o.camera.pixelRatio)),new t("glowFalloff",(e=>e.glowFalloff)),new l("innerColor",(e=>e.innerColor)),new t("innerWidth",((e,o)=>e.innerWidth*o.camera.pixelRatio)),new a("depthMap",(e=>e.depth?.attachment)),new n("normalMap",(e=>e.normals))),d.code.add(r`vec4 blendPremultiplied(vec4 source, vec4 dest) { float oneMinusSourceAlpha = 1.0 - source.a; return vec4( source.rgb + dest.rgb * oneMinusSourceAlpha, source.a + dest.a * oneMinusSourceAlpha ); }`),d.code.add(r`vec4 premultipliedColor(vec3 rgb, float alpha) { return vec4(rgb * alpha, alpha); }`),d.code.add(r`vec4 laserlineProfile(float dist) { if (dist > glowWidth) { return vec4(0.0); } float innerAlpha = (1.0 - smoothstep(0.0, innerWidth, dist)); float glowAlpha = pow(max(0.0, 1.0 - dist / glowWidth), glowFalloff); return blendPremultiplied( premultipliedColor(innerColor, innerAlpha), premultipliedColor(glowColor, glowAlpha) ); }`),d.code.add(r`bool laserlineReconstructFromDepth(out vec3 pos, out vec3 normal, out float angleCutoffAdjust, out float depthDiscontinuityAlpha) { float depth = depthFromTexture(depthMap, uv); if (depth == 1.0) { return false; } float linearDepth = linearizeDepth(depth); pos = reconstructPosition(gl_FragCoord.xy, linearDepth); float minStep = 6e-8; float depthStep = clamp(depth + minStep, 0.0, 1.0); float linearDepthStep = linearizeDepth(depthStep); float depthError = abs(linearDepthStep - linearDepth); if (depthError > 0.2) { normal = texture(normalMap, uv).xyz * 2.0 - 1.0; angleCutoffAdjust = 0.004; } else { normal = normalize(cross(dFdx(pos), dFdy(pos))); angleCutoffAdjust = 0.0; } float ddepth = fwidth(linearDepth); depthDiscontinuityAlpha = 1.0 - smoothstep(0.0, 0.01, -ddepth / linearDepth); return true; }`),p.contrastControlEnabled?d.uniforms.add(new n("frameColor",((e,o)=>e.colors)),new t("globalAlphaContrastBoost",(e=>e.globalAlphaContrastBoost))).code.add(r`float rgbToLuminance(vec3 color) { return dot(vec3(0.2126, 0.7152, 0.0722), color); } vec4 laserlineOutput(vec4 color) { float backgroundLuminance = rgbToLuminance(texture(frameColor, uv).rgb); float alpha = clamp(globalAlpha * max(backgroundLuminance * globalAlphaContrastBoost, 1.0), 0.0, 1.0); return color * alpha; }`):d.code.add(r`vec4 laserlineOutput(vec4 color) { return color * globalAlpha; }`)}export{i as Laserline};