Heatmap.glsl.js 1.6 KB

123456789101112131415
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.js";import{DiscardOrAdjustAlphaBlend as r}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js";import{FloatPassUniform as i}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as s}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as o}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as n}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";function t(t){const a=new o;a.include(e),a.include(r);const{usesHalfFloat:d}=t;return a.fragment.uniforms.add([new n("densityMap",(e=>e.densityMap)),new n("tex",(e=>e.colorRamp)),new i("densityNormalizer",(e=>1/(e.maxDensity-e.minDensity))),new i("minDensity",(e=>e.minDensity))]),a.fragment.uniforms.add(new i("densityMultiplier",(e=>3/(e.searchRadius*e.searchRadius*Math.PI)))),d&&a.constants.add("compressionFactor","float",4),a.fragment.code.add(s`
  6. void main() {
  7. float density = texture2D(densityMap, uv).r * densityMultiplier${d?s` * compressionFactor`:""};
  8. float densityRatio = (density - minDensity) * densityNormalizer;
  9. vec4 color = texture2D(tex, vec2(clamp(densityRatio, 0.0, 1.0), 0.5));
  10. discardOrAdjustAlpha(color);
  11. gl_FragColor = color;
  12. }
  13. `),a}const a=Object.freeze(Object.defineProperty({__proto__:null,build:t},Symbol.toStringTag,{value:"Module"}));export{a as H,t as b};