SlicePlaneMaterial.glsl.js 1.8 KB

1234567891011121314151617181920
  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{addProjViewLocalOrigin as e}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float4PassUniform as r}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/interfaces.js";import{ShaderBuilder as i}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{VertexAttribute as a}from"../views/3d/webgl-engine/lib/VertexAttribute.js";function t(t){const g=new i;g.extensions.add("GL_OES_standard_derivatives");const{vertex:l,fragment:s,attributes:n,varyings:c}=g;return e(l,t),n.add(a.POSITION,"vec3"),n.add(a.UV0,"vec2"),c.add("vUV","vec2"),l.code.add(o`void main(void) {
  6. vUV = uv0;
  7. gl_Position = proj * view * vec4(position, 1.0);
  8. }`),s.uniforms.add([new r("backgroundColor",(e=>e.backgroundColor)),new r("gridColor",(e=>e.gridColor)),new d("gridWidth",(e=>e.gridWidth))]),s.code.add(o`void main() {
  9. const float LINE_WIDTH = 1.0;
  10. vec2 uvScaled = vUV * gridWidth;
  11. vec2 gridUV = (fract(uvScaled + 0.5) - 0.5) / (LINE_WIDTH * fwidth(uvScaled));
  12. vec2 grid = (1.0 - step(0.5, gridUV)) * step(-0.5, gridUV);
  13. grid.x *= step(0.5, uvScaled.x) * step(uvScaled.x, gridWidth - 0.5);
  14. grid.y *= step(0.5, uvScaled.y) * step(uvScaled.y, gridWidth - 0.5);
  15. float gridFade = max(grid.x, grid.y);
  16. float gridAlpha = gridColor.a * gridFade;
  17. gl_FragColor =
  18. vec4(backgroundColor.rgb * backgroundColor.a, backgroundColor.a) * (1.0 - gridAlpha) +
  19. vec4(gridColor.rgb, 1.0) * gridAlpha;
  20. }`),g}const g=Object.freeze(Object.defineProperty({__proto__:null,build:t},Symbol.toStringTag,{value:"Module"}));export{g as S,t as b};