@itwin/core-frontend
Version:
iTwin.js frontend components
18 lines • 2.46 kB
TypeScript
/** @packageDocumentation
* @module WebGL
*/
import { FragmentShaderBuilder, ProgramBuilder, VertexShaderBuilder } from "../ShaderBuilder";
import { IsInstanced, PositionType } from "../TechniqueFlags";
/** @internal */
export declare const adjustWidth = "\nvoid adjustWidth(inout float width, vec2 d2, vec2 org) {\n if (u_aaSamples > 1) {\n if (width < 5.0)\n width += (5.0 - width) * 0.125;\n return;\n }\n\n // calculate slope based width adjustment for non-AA lines, widths 1 to 4\n vec2 d2A = abs(d2);\n const float s_myFltEpsilon = 0.0001; // limit test resolution to 4 digits in case 24 bit (s16e7) is used in hardware\n if (d2A.y > s_myFltEpsilon && width < 4.5) {\n float len = length(d2A);\n float tan = d2A.x / d2A.y;\n\n if (width < 1.5) { // width 1\n if (tan <= 1.0)\n width = d2A.y;\n else\n width = d2A.x;\n // width 1 requires additional adjustment plus trimming in frag shader using v_lnInfo\n width *= 1.01;\n v_lnInfo.xy = org;\n v_lnInfo.w = 1.0; // set flag to do trimming\n // set slope in v_lnInfo.z\n if (d2A.x - d2A.y > s_myFltEpsilon) {\n v_lnInfo.z = d2.y / d2.x;\n v_lnInfo.w += 2.0; // add in x-major flag\n } else\n v_lnInfo.z = d2.x / d2.y;\n\n } else if (width < 2.5) { // width 2\n if (tan <= 0.5)\n width = 2.0 * d2A.y;\n else\n width = (d2A.y + 2.0 * d2A.x);\n\n } else if (width < 3.5) { // width 3\n if (tan <= 1.0)\n width = (3.0 * d2A.y + d2A.x);\n else\n width = (d2A.y + 3.0 * d2A.x);\n\n } else { // if (width < 4.5) // width 4\n if (tan <= 0.5)\n width = (4.0 * d2A.y + d2A.x);\n else if (tan <= 2.0)\n width = (3.0 * d2A.y + 3.0 * d2A.x);\n else\n width = (d2A.y + 4.0 * d2A.x);\n }\n width /= len;\n }\n}\n";
/** @internal */
export declare function addAdjustWidth(vert: VertexShaderBuilder): void;
/** @internal */
export declare function addLineCodeTexture(frag: FragmentShaderBuilder): void;
/** @internal */
export declare function addLineCode(prog: ProgramBuilder, args: string): void;
/** @internal */
export declare function createPolylineBuilder(isInstanced: IsInstanced, positionType: PositionType): ProgramBuilder;
/** @internal */
export declare function createPolylineHiliter(isInstanced: IsInstanced, positionType: PositionType): ProgramBuilder;
//# sourceMappingURL=Polyline.d.ts.map