123456789101112131415161718192021222324252627282930313233343536373839 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{glsl as e}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 r}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{VertexAttribute as t}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{addResolutionUniform as s}from"../views/3d/webgl-engine/shaders/SMAAPassParameters.js";function d(){const d=new o,{attributes:f,varyings:i,vertex:n,fragment:x}=d;return f.add(t.POSITION,"vec2"),i.add("fTexCoord","vec2"),i.add("fOffset[2]","vec4"),s(n),n.code.add(e`void SMAANeighborhoodBlendingVS( vec2 texcoord ) {
- fOffset[0] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );
- fOffset[1] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );
- }
- void main() {
- fTexCoord = (position + 1.0 ) * 0.5;
- gl_Position = vec4(position, 0, 1);
- SMAANeighborhoodBlendingVS(fTexCoord);
- }`),x.uniforms.add(new r("tBlendWeights",(e=>e.blend.colorTexture))),x.uniforms.add(new r("tColor",(e=>e.colorTexture))),s(x),x.code.add(e`vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {
- vec4 a;
- a.xz = texture2D( blendTex, texcoord ).xz;
- a.y = texture2D( blendTex, offset[ 1 ].zw ).g;
- a.w = texture2D( blendTex, offset[ 1 ].xy ).a;
- if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {
- return texture2D( colorTex, texcoord, 0.0 );
- } else {
- vec2 offset;
- offset.x = a.a > a.b ? a.a : -a.b;
- offset.y = a.g > a.r ? -a.g : a.r;
- if ( abs( offset.x ) > abs( offset.y )) {
- offset.y = 0.0;
- } else {
- offset.x = 0.0;
- }
- vec4 C = texture2D( colorTex, texcoord, 0.0 );
- texcoord += sign( offset ) * resolution.xy;
- vec4 Cop = texture2D( colorTex, texcoord, 0.0 );
- float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );
- vec4 mixed = mix(C, Cop, s);
- return mixed;
- }
- }
- void main() {
- gl_FragColor = SMAANeighborhoodBlendingPS( fTexCoord, fOffset, tColor, tBlendWeights );
- }`),d}const f=Object.freeze(Object.defineProperty({__proto__:null,build:d},Symbol.toStringTag,{value:"Module"}));export{f as B,d as b};
|