/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{addProjViewLocalOrigin as r}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float4PassUniform as e}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as d}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as o}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{ShaderBuilder as i}from"../views/webgl/ShaderBuilder.js";function a(a){const g=new i,{vertex:l,fragment:t,attributes:s,varyings:n}=g;return r(l,a),s.add("position","vec3"),s.add("uv0","vec2"),n.add("vUV","vec2"),l.main.add(o`vUV = uv0;
gl_Position = proj * view * vec4(position, 1.0);`),t.uniforms.add(new e("backgroundColor",r=>r.backgroundColor),new e("gridColor",r=>r.gridColor),new d("gridWidth",r=>r.gridWidth)).main.add(o`const float LINE_WIDTH = 1.0;
vec2 uvScaled = vUV * gridWidth;
vec2 gridUV = (fract(uvScaled + 0.5) - 0.5) / (LINE_WIDTH * fwidth(uvScaled));
vec2 grid = (1.0 - step(0.5, gridUV)) * step(-0.5, gridUV);
grid.x *= step(0.5, uvScaled.x) * step(uvScaled.x, gridWidth - 0.5);
grid.y *= step(0.5, uvScaled.y) * step(uvScaled.y, gridWidth - 0.5);
float gridFade = max(grid.x, grid.y);
float gridAlpha = gridColor.a * gridFade;
fragColor =
vec4(backgroundColor.rgb * backgroundColor.a, backgroundColor.a) * (1.0 - gridAlpha) +
vec4(gridColor.rgb, 1.0) * gridAlpha;`),g}const g=Object.freeze(Object.defineProperty({__proto__:null,build:a},Symbol.toStringTag,{value:"Module"}));export{g as S,a as b};
