/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{neverReached as e}from"../../../../../../core/compilerUtils.js";import{FloatDrawUniform as t}from"../../../core/shaderModules/FloatDrawUniform.js";import{glsl as r}from"../../../core/shaderModules/glsl.js";import{Texture2DDrawUniform as s}from"../../../core/shaderModules/Texture2DDrawUniform.js";import{usesSketchLogic as a}from"./EdgeUtil.glsl.js";import{UnpackAttributes as u}from"./UnpackAttributes.glsl.js";import{NoParameters as c}from"../../../../../webgl/NoParameters.js";class l extends c{}function o(c,l){c.include(u,l);const{vertex:o,fragment:n}=c;switch(a(l.type)&&(c.varyings.add("vStrokeUV","vec2"),o.uniforms.add(new s("strokesTexture",e=>e.strokesTexture.texture),new t("strokesLog2Resolution",e=>Math.log2(e.strokesTexture.resolution)),new t("strokeVariants",e=>e.strokesTexture.variants)).code.add(r`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) / vec2(textureSize(strokesTexture, 0));
vStrokeUV.x += variantOffset;
}`),n.uniforms.add(new s("strokesTexture",e=>e.strokesTexture.texture)).code.add(r`float calculateLineOffsetSketch() {
return texture(strokesTexture, vStrokeUV).r;
}
float calculateLinePressureSketch() {
return texture(strokesTexture, vStrokeUV + vec2(0.0, 0.5)).r;
}`)),l.type){case 0:o.code.add(r`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes) {}`),n.code.add(r`float calculateLineOffset() {
return 0.0;
}
float calculateLinePressure() {
return 1.0;
}`);break;case 1:o.code.add(r`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes)
{
calculateStyleOutputsSketch(vLineLengthPixels, unpackedAttributes);
}`),n.code.add(r`float calculateLineOffset() {
return calculateLineOffsetSketch();
}
float calculateLinePressure() {
return calculateLinePressureSketch();
}`);break;case 2:c.varyings.add("vType","float"),o.code.add(r`void calculateStyleOutputs(UnpackedAttributes unpackedAttributes)
{
vType = unpackedAttributes.type;
if (unpackedAttributes.type <= 0.0) {
calculateStyleOutputsSketch(vLineLengthPixels, unpackedAttributes);
}
}`),n.code.add(r`float calculateLineOffset() {
if (vType <= 0.0) {
return calculateLineOffsetSketch();
}
else {
return 0.0;
}
}
float calculateLinePressure() {
if (vType <= 0.0) {
return calculateLinePressureSketch();
}
else {
return 1.0;
}
}`);break;case 3:break;default:e(l.type)}}export{o as LineOffset,l as LineOffsetDrawParameters};
