/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl","../views/3d/webgl-engine/core/shaderModules/FloatPassUniform","../views/3d/webgl-engine/core/shaderModules/interfaces","../views/3d/webgl-engine/core/shaderModules/ShaderBuilder","../views/3d/webgl-engine/lib/VertexAttribute"],(function(e,t,i,r,a,o){"use strict";function d(e){const d=new a.ShaderBuilder;t.addProjViewLocalOrigin(d,e);const{isAttributeDriven:s}=e;return d.attributes.add(o.VertexAttribute.POSITION,"vec3"),d.attributes.add(o.VertexAttribute.UV0,"vec2"),s&&(d.attributes.add(o.VertexAttribute.FEATUREATTRIBUTE,"float"),d.varyings.add("attributeValue","float")),d.varyings.add("unitCirclePos","vec2"),d.vertex.uniforms.add(new i.FloatPassUniform("radius",(({resolutionForScale:e,searchRadius:t},{camera:i,screenToWorldRatio:r})=>2*t*(0===e?1:e/r)*i.pixelRatio/i.fullViewport[2]))),d.vertex.code.add(r.glsl`
    void main() {
      unitCirclePos = uv0;

      vec4 posProj = proj * (view * vec4(${o.VertexAttribute.POSITION}, 1.0));
      vec4 quadOffset = vec4(unitCirclePos * radius, 0.0, 0.0);

      ${s?r.glsl`attributeValue = ${o.VertexAttribute.FEATUREATTRIBUTE};`:""}
      gl_Position = posProj + quadOffset;
    }
  `),d.fragment.code.add(r.glsl`
    void main() {
      float radiusRatioSquared = dot(unitCirclePos, unitCirclePos);
      if (radiusRatioSquared > 1.0) {
        discard;
      }

      float oneMinusRadiusRatioSquared = 1.0 - radiusRatioSquared;
      float density = oneMinusRadiusRatioSquared * oneMinusRadiusRatioSquared ${s?r.glsl` * attributeValue`:""};
      gl_FragColor = vec4(density);
    }
  `),d}const s=Object.freeze(Object.defineProperty({__proto__:null,build:d},Symbol.toStringTag,{value:"Module"}));e.HeatmapDensity=s,e.build=d}));
