import type { PickingProps, PickingUniforms } from "./picking-uniforms.js"; /** * Unified object-picking shader module. * Uses color picking on GLSL/WebGL paths and index picking on WGSL/WebGPU paths. */ export declare const picking: { readonly name: "picking"; readonly source: "struct pickingUniforms {\n isActive: i32,\n indexMode: i32,\n batchIndex: i32,\n\n isHighlightActive: i32,\n highlightedBatchIndex: i32,\n highlightedObjectIndex: i32,\n highlightColor: vec4,\n};\n\n@group(0) @binding(auto) var picking: pickingUniforms;\n\n\nconst INDEX_PICKING_MODE_INSTANCE = 0;\nconst INDEX_PICKING_MODE_CUSTOM = 1;\nconst INDEX_PICKING_INVALID_INDEX = -1; // 2^32 - 1\n\n/**\n * WGSL shaders need to carry the returned object index through their own stage outputs.\n */\nfn picking_setObjectIndex(objectIndex: i32) -> i32 {\n return objectIndex;\n}\n\nfn picking_isObjectHighlighted(objectIndex: i32) -> bool {\n return\n picking.isHighlightActive != 0 &&\n picking.highlightedBatchIndex == picking.batchIndex &&\n picking.highlightedObjectIndex == objectIndex;\n}\n\nfn picking_filterHighlightColor(color: vec4, objectIndex: i32) -> vec4 {\n if (picking.isActive != 0 || !picking_isObjectHighlighted(objectIndex)) {\n return color;\n }\n\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n if (blendedAlpha == 0.0) {\n return vec4(color.rgb, 0.0);\n }\n\n let highLightRatio = highLightAlpha / blendedAlpha;\n let blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nfn picking_filterPickingColor(color: vec4, objectIndex: i32) -> vec4 {\n if (picking.isActive != 0 && objectIndex == INDEX_PICKING_INVALID_INDEX) {\n discard;\n }\n return color;\n}\n\nfn picking_getPickingColor(objectIndex: i32) -> vec2 {\n return vec2(objectIndex, picking.batchIndex);\n}\n\n"; readonly vs: "precision highp float;\nprecision highp int;\n\nlayout(std140) uniform pickingUniforms {\n int isActive;\n int indexMode;\n int batchIndex;\n\n int isHighlightActive;\n int highlightedBatchIndex;\n int highlightedObjectIndex;\n vec4 highlightColor;\n} picking;\n\n\nconst int INDEX_PICKING_MODE_INSTANCE = 0;\nconst int INDEX_PICKING_MODE_CUSTOM = 1;\n\nconst int COLOR_PICKING_INVALID_INDEX = -1;\n\nflat out int picking_objectIndex;\n\nvoid picking_setObjectIndex(int objectIndex) {\n switch (picking.indexMode) {\n case INDEX_PICKING_MODE_INSTANCE:\n picking_objectIndex = gl_InstanceID;\n break;\n case INDEX_PICKING_MODE_CUSTOM:\n picking_objectIndex = objectIndex;\n break;\n }\n}\n"; readonly fs: "precision highp float;\nprecision highp int;\n\nlayout(std140) uniform pickingUniforms {\n int isActive;\n int indexMode;\n int batchIndex;\n\n int isHighlightActive;\n int highlightedBatchIndex;\n int highlightedObjectIndex;\n vec4 highlightColor;\n} picking;\n\n\nconst int COLOR_PICKING_INVALID_INDEX = -1;\nconst int COLOR_PICKING_MAX_OBJECT_INDEX = 16777214;\nconst int COLOR_PICKING_MAX_BATCH_INDEX = 254;\n\nflat in int picking_objectIndex;\n\nbool picking_isFragmentHighlighted() {\n return\n bool(picking.isHighlightActive) &&\n picking.highlightedBatchIndex == picking.batchIndex &&\n picking.highlightedObjectIndex == picking_objectIndex\n ;\n}\n\nvec4 picking_filterHighlightColor(vec4 color) {\n if (bool(picking.isActive)) {\n return color;\n }\n\n if (!picking_isFragmentHighlighted()) {\n return color;\n }\n\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nbool picking_canEncodePickInfo(int objectIndex) {\n return\n objectIndex != COLOR_PICKING_INVALID_INDEX &&\n objectIndex >= 0 &&\n objectIndex <= COLOR_PICKING_MAX_OBJECT_INDEX &&\n picking.batchIndex >= 0 &&\n picking.batchIndex <= COLOR_PICKING_MAX_BATCH_INDEX;\n}\n\nvec4 picking_getPickingColor() {\n if (!picking_canEncodePickInfo(picking_objectIndex)) {\n return vec4(0.0);\n }\n\n int encodedObjectIndex = picking_objectIndex + 1;\n int red = encodedObjectIndex % 256;\n int green = (encodedObjectIndex / 256) % 256;\n int blue = (encodedObjectIndex / 65536) % 256;\n int alpha = picking.batchIndex + 1;\n\n return vec4(float(red), float(green), float(blue), float(alpha)) / 255.0;\n}\n\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (!picking_canEncodePickInfo(picking_objectIndex)) {\n discard;\n }\n return picking_getPickingColor();\n }\n\n return color;\n}\n\nvec4 picking_filterColor(vec4 color) {\n vec4 outColor = color;\n outColor = picking_filterHighlightColor(outColor);\n outColor = picking_filterPickingColor(outColor);\n return outColor;\n}\n"; readonly props: PickingProps; readonly uniforms: PickingUniforms; readonly uniformTypes: Required>; readonly defaultUniforms: { readonly isActive: false; readonly indexMode: 0; readonly batchIndex: 0; readonly isHighlightActive: false; readonly highlightedBatchIndex: -1; readonly highlightedObjectIndex: -1; readonly highlightColor: import("@math.gl/types").NumberArray4; }; readonly getUniforms: (props?: PickingProps, prevUniforms?: PickingUniforms) => PickingUniforms; }; //# sourceMappingURL=picking.d.ts.map