/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../core/shaderLibrary/util/RgbaFloatEncoding.glsl","../../../core/shaderModules/Float2Uniform","../../../core/shaderModules/FloatUniform","../../../core/shaderModules/interfaces","../../../core/shaderModules/Texture2DUniform","./EdgeUtil.glsl","./UnpackAttributes.glsl"],(function(e,t,a,r,l,s,o,n){"use strict";function u(e,u){const c=e.vertex;e.include(n.UnpackAttributes,u);const i=e.fragment;switch(o.usesSketchLogic(u)&&(c.uniforms.add(new a.Float2Uniform("strokesTextureScale")),c.uniforms.add(new r.FloatUniform("strokesLog2Resolution")),c.uniforms.add(new r.FloatUniform("strokeVariants")),e.varyings.add("vStrokeUV","vec2"),i.uniforms.add(new s.Texture2DUniform("strokesTexture")),i.uniforms.add(new r.FloatUniform("strokesNormalizationScale")),c.code.add(l.glsl`void calculateStyleOutputsSketch(float lineLength, UnpackedAttributes unpackedAttributes) {
vec2 sidenessNorm = unpackedAttributes.sidenessNorm;
float lineIndex = clamp(ceil(log2(lineLength)), 0.0, strokesLog2Resolution);
vStrokeUV = vec2(exp2(lineIndex) * sidenessNorm.y, lineIndex * strokeVariants + variantStroke + 0.5) * strokesTextureScale;
vStrokeUV.x += variantOffset;
}`),e.fragment.include(t.RgbaFloatEncoding),i.code.add(l.glsl`float calculateLineOffsetSketch() {
float offsetNorm = rgba2float(texture2D(strokesTexture, vStrokeUV));
return (offsetNorm - 0.5) * strokesNormalizationScale;
}
float calculateLinePressureSketch() {
return rgba2float(texture2D(strokesTexture, vStrokeUV + vec2(0.0, 0.5)));
}`)),u.mode){case o.EdgeUtilMode.SOLID:c.code.add(l.glsl`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes) {}`),i.code.add(l.glsl`float calculateLineOffset() {
return 0.0;
}
float calculateLinePressure() {
return 1.0;
}`);break;case o.EdgeUtilMode.SKETCH:c.code.add(l.glsl`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes)
{
calculateStyleOutputsSketch(vLineLengthPixels, unpackedAttributes);
}`),i.code.add(l.glsl`float calculateLineOffset() {
return calculateLineOffsetSketch();
}
float calculateLinePressure() {
return calculateLinePressureSketch();
}`);break;case o.EdgeUtilMode.MIXED:e.varyings.add("vType","float"),c.code.add(l.glsl`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes)
{
vType = unpackedAttributes.type;
if (unpackedAttributes.type <= 0.0) {
calculateStyleOutputsSketch(vLineLengthPixels, unpackedAttributes);
}
}`),i.code.add(l.glsl`float calculateLineOffset() {
if (vType <= 0.0) {
return calculateLineOffsetSketch();
}
else {
return 0.0;
}
}
float calculateLinePressure() {
if (vType <= 0.0) {
return calculateLinePressureSketch();
}
else {
return 1.0;
}
}`)}}e.LineOffset=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
