UNPKG

@arcgis/core

Version:

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

38 lines (37 loc) 2.33 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{Projection as o}from"./Projection.glsl.js";import{TileCompositePassParameters as e}from"../terrain/TileComposite.glsl.js";import{BooleanPassUniform as r}from"../../shaderModules/BooleanPassUniform.js";import{Float2PassUniform as c}from"../../shaderModules/Float2PassUniform.js";import{glsl as t}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as l}from"../../shaderModules/Texture2DPassUniform.js";class a extends e{constructor(o,e,r){super(),this.common=o,this.u_image=e,this.u_transformGrid=r}}function i(e,a){e.include(o),e.fragment.uniforms.add(new l("u_image",o=>o.u_image),new r("u_flipY",o=>o.common.u_flipY),new r("u_applyTransform",o=>o.common.u_applyTransform));const{requireBilinearWithNN:i}=a;i&&e.fragment.uniforms.add(new c("u_srcImageSize",o=>o.common.u_srcImageSize)),e.fragment.code.add(t`vec2 getPixelLocation(vec2 coords) { vec2 targetLocation = u_flipY ? vec2(coords.s, 1.0 - coords.t) : coords; if (!u_applyTransform) { return targetLocation; } return projectPixelLocation(targetLocation); } bool isOutside(vec2 coords){ if (coords.t>1.00001 ||coords.t<-0.00001 || coords.s>1.00001 ||coords.s<-0.00001) { return true; } else { return false; } }`),i?e.fragment.code.add(t`vec4 sampleBilinear(sampler2D sampler, vec2 coords, vec2 texSize) { vec2 texelStart = floor(coords * texSize); vec2 coord0 = texelStart / texSize; vec2 coord1 = (texelStart + vec2(1.0, 0.0)) / texSize; vec2 coord2 = (texelStart + vec2(0.0, 1.0)) / texSize; vec2 coord3 = (texelStart + vec2(1.0, 1.0)) / texSize; vec4 color0 = texture(sampler, coord0); vec4 color1 = texture(sampler, coord1); vec4 color2 = texture(sampler, coord2); vec4 color3 = texture(sampler, coord3); vec2 blend = fract(coords * texSize); vec4 color01 = mix(color0, color1, blend.x); vec4 color23 = mix(color2, color3, blend.x); vec4 color = mix(color01, color23, blend.y); float alpha = floor(color0.a * color1.a * color2.a * color3.a + 0.5); color = color * alpha + (1.0 - alpha) * texture(sampler, coords); return color; } vec4 getPixel(vec2 pixelLocation) { return sampleBilinear(u_image, pixelLocation, u_srcImageSize); }`):e.fragment.code.add(t`vec4 getPixel(vec2 pixelLocation) { return texture(u_image, pixelLocation); }`)}export{i as Common,a as CommonPassParameters};