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