@vitessce/gl 2.0.3-beta.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/deflate-36830437.js +11 -0
  2. package/dist/index-d34ff949.js +120610 -0
  3. package/dist/index.js +33 -16
  4. package/dist/jpeg-a66190dc.js +838 -0
  5. package/dist/lerc-21af7ec8.js +2004 -0
  6. package/dist/lzw-76194936.js +126 -0
  7. package/dist/packbits-bf7850c4.js +28 -0
  8. package/dist/pako.esm-68f84e2a.js +4022 -0
  9. package/dist/raw-05d82ade.js +10 -0
  10. package/dist/webimage-1ceac06a.js +30 -0
  11. package/dist-tsc/BitmaskLayer.d.ts +74 -0
  12. package/dist-tsc/BitmaskLayer.d.ts.map +1 -0
  13. package/{dist → dist-tsc}/BitmaskLayer.js +14 -4
  14. package/dist-tsc/HeatmapBitmapLayer.d.ts +93 -0
  15. package/dist-tsc/HeatmapBitmapLayer.d.ts.map +1 -0
  16. package/{dist → dist-tsc}/HeatmapBitmapLayer.js +3 -3
  17. package/dist-tsc/HeatmapCompositeTextLayer.d.ts +11 -0
  18. package/dist-tsc/HeatmapCompositeTextLayer.d.ts.map +1 -0
  19. package/{dist → dist-tsc}/HeatmapCompositeTextLayer.js +1 -1
  20. package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts +93 -0
  21. package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts.map +1 -0
  22. package/{dist → dist-tsc}/PaddedExpressionHeatmapBitmapLayer.js +3 -3
  23. package/dist-tsc/PixelatedBitmapLayer.d.ts +10 -0
  24. package/dist-tsc/PixelatedBitmapLayer.d.ts.map +1 -0
  25. package/{dist → dist-tsc}/PixelatedBitmapLayer.js +1 -1
  26. package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts +62 -0
  27. package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts.map +1 -0
  28. package/{dist → dist-tsc}/ScaledExpressionExtension/ScaledExpressionExtension.js +2 -2
  29. package/dist-tsc/ScaledExpressionExtension/index.d.ts +3 -0
  30. package/dist-tsc/ScaledExpressionExtension/index.d.ts.map +1 -0
  31. package/{dist → dist-tsc}/ScaledExpressionExtension/index.js +1 -1
  32. package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts +17 -0
  33. package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts.map +1 -0
  34. package/{dist → dist-tsc}/ScaledExpressionExtension/shader-module.js +1 -1
  35. package/dist-tsc/SelectionExtension/SelectionExtension.d.ts +18 -0
  36. package/dist-tsc/SelectionExtension/SelectionExtension.d.ts.map +1 -0
  37. package/{dist → dist-tsc}/SelectionExtension/SelectionExtension.js +1 -1
  38. package/dist-tsc/SelectionExtension/index.d.ts +3 -0
  39. package/dist-tsc/SelectionExtension/index.d.ts.map +1 -0
  40. package/dist-tsc/SelectionExtension/index.js +2 -0
  41. package/dist-tsc/SelectionExtension/shader-module.d.ts +12 -0
  42. package/dist-tsc/SelectionExtension/shader-module.d.ts.map +1 -0
  43. package/dist-tsc/SelectionLayer.d.ts +15 -0
  44. package/dist-tsc/SelectionLayer.d.ts.map +1 -0
  45. package/{dist → dist-tsc}/SelectionLayer.js +1 -11
  46. package/dist-tsc/bitmask-layer-shaders.d.ts +3 -0
  47. package/dist-tsc/bitmask-layer-shaders.d.ts.map +1 -0
  48. package/{dist → dist-tsc}/bitmask-layer-shaders.js +1 -1
  49. package/dist-tsc/constants.d.ts +8 -0
  50. package/dist-tsc/constants.d.ts.map +1 -0
  51. package/dist-tsc/deck.d.ts +2 -0
  52. package/dist-tsc/deck.d.ts.map +1 -0
  53. package/dist-tsc/glsl/index.d.ts +2 -0
  54. package/dist-tsc/glsl/index.d.ts.map +1 -0
  55. package/dist-tsc/heatmap-bitmap-layer-shaders.d.ts +13 -0
  56. package/dist-tsc/heatmap-bitmap-layer-shaders.d.ts.map +1 -0
  57. package/{dist → dist-tsc}/heatmap-bitmap-layer-shaders.js +1 -1
  58. package/dist-tsc/heatmap-constants.d.ts +20 -0
  59. package/dist-tsc/heatmap-constants.d.ts.map +1 -0
  60. package/dist-tsc/index.d.ts +14 -0
  61. package/dist-tsc/index.d.ts.map +1 -0
  62. package/dist-tsc/index.js +19 -0
  63. package/dist-tsc/luma.d.ts +2 -0
  64. package/dist-tsc/luma.d.ts.map +1 -0
  65. package/dist-tsc/padded-expression-heatmap-bitmap-layer-shaders.d.ts +13 -0
  66. package/dist-tsc/padded-expression-heatmap-bitmap-layer-shaders.d.ts.map +1 -0
  67. package/{dist → dist-tsc}/padded-expression-heatmap-bitmap-layer-shaders.js +1 -1
  68. package/dist-tsc/selection-utils.d.ts +19 -0
  69. package/dist-tsc/selection-utils.d.ts.map +1 -0
  70. package/{dist → dist-tsc}/selection-utils.js +1 -1
  71. package/dist-tsc/viv.d.ts +2 -0
  72. package/dist-tsc/viv.d.ts.map +1 -0
  73. package/package.json +16 -7
  74. package/src/BitmaskLayer.js +175 -0
  75. package/src/HeatmapBitmapLayer.js +144 -0
  76. package/src/HeatmapCompositeTextLayer.js +156 -0
  77. package/src/PaddedExpressionHeatmapBitmapLayer.js +154 -0
  78. package/src/PixelatedBitmapLayer.js +30 -0
  79. package/src/ScaledExpressionExtension/ScaledExpressionExtension.js +117 -0
  80. package/src/ScaledExpressionExtension/index.js +3 -0
  81. package/src/ScaledExpressionExtension/shader-module.js +35 -0
  82. package/src/SelectionExtension/SelectionExtension.js +34 -0
  83. package/src/SelectionExtension/index.js +3 -0
  84. package/src/SelectionExtension/shader-module.js +22 -0
  85. package/src/SelectionLayer.js +187 -0
  86. package/src/bitmask-layer-shaders.js +92 -0
  87. package/src/constants.js +13 -0
  88. package/src/deck.js +4 -0
  89. package/src/glsl/README.md +8 -0
  90. package/src/glsl/colormaps.in.glsl +15 -0
  91. package/src/glsl/index.js +341 -0
  92. package/src/heatmap-bitmap-layer-shaders.js +111 -0
  93. package/src/heatmap-constants.js +30 -0
  94. package/src/index.js +36 -0
  95. package/src/luma.js +2 -0
  96. package/src/padded-expression-heatmap-bitmap-layer-shaders.js +145 -0
  97. package/src/selection-utils.js +109 -0
  98. package/src/viv.js +20 -0
  99. package/dist/SelectionExtension/index.js +0 -2
  100. package/dist/layer-controller.js +0 -109
  101. package/dist/spatial.js +0 -281
  102. package/dist/spatial.test.js +0 -8
  103. /package/{dist → dist-tsc}/SelectionExtension/shader-module.js +0 -0
  104. /package/{dist → dist-tsc}/constants.js +0 -0
  105. /package/{dist → dist-tsc}/deck.js +0 -0
  106. /package/{dist → dist-tsc}/glsl/index.js +0 -0
  107. /package/{dist → dist-tsc}/heatmap-constants.js +0 -0
  108. /package/{dist → dist-tsc}/luma.js +0 -0
  109. /package/{dist → dist-tsc}/viv.js +0 -0
@@ -0,0 +1,22 @@
1
+ const vs = `
2
+ attribute float isSelected;
3
+ `;
4
+
5
+ const inject = {
6
+ 'vs:DECKGL_FILTER_GL_POSITION': `
7
+ position.z += (1. - isSelected) * .00005; // Add a small z offset for unselected points in the positive direction i.e into the screen.
8
+ `,
9
+ 'fs:#main-start': ` // Gets rid of bad border effects (active after deck.gl 8.5): https://github.com/visgl/deck.gl/pull/6081
10
+ float distToCenterNew = length(unitPosition) * outerRadiusPixels;
11
+ float inCircleNew = step(distToCenterNew, outerRadiusPixels);
12
+ if (inCircleNew == 0.0) {
13
+ discard;
14
+ }
15
+ `,
16
+ };
17
+
18
+ export default {
19
+ name: 'selection',
20
+ vs,
21
+ inject,
22
+ };
@@ -0,0 +1,187 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ /* eslint-disable no-underscore-dangle */
3
+ // File adopted from nebula.gl's SelectionLayer
4
+ // https://github.com/uber/nebula.gl/blob/8e9c2ec8d7cf4ca7050909ed826eb847d5e2cd9c/modules/layers/src/layers/selection-layer.js
5
+ import { CompositeLayer } from 'deck.gl';
6
+ import { polygon as turfPolygon, point as turfPoint } from '@turf/helpers';
7
+ import booleanWithin from '@turf/boolean-within';
8
+ import booleanContains from '@turf/boolean-contains';
9
+ import booleanOverlap from '@turf/boolean-overlap';
10
+ import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
11
+ import { ScatterplotLayer } from '@deck.gl/layers';
12
+ import { SELECTION_TYPE } from 'nebula.gl';
13
+ import { EditableGeoJsonLayer } from '@nebula.gl/layers';
14
+ import { DrawPolygonByDraggingMode, ViewMode } from '@nebula.gl/edit-modes';
15
+
16
+ const EDIT_TYPE_ADD = 'addFeature';
17
+ const EDIT_TYPE_CLEAR = 'clearFeatures';
18
+
19
+ class ClickableDrawPolygonByDraggingMode extends DrawPolygonByDraggingMode {
20
+ // eslint-disable-next-line class-methods-use-this
21
+ handleClick(event, props) {
22
+ props.onEdit({ editType: EDIT_TYPE_CLEAR });
23
+ }
24
+ }
25
+
26
+ const MODE_MAP = {
27
+ [SELECTION_TYPE.POLYGON]: ClickableDrawPolygonByDraggingMode,
28
+ };
29
+
30
+ const defaultProps = {
31
+ layerIds: [],
32
+ onSelect: () => {},
33
+ };
34
+
35
+ const EMPTY_DATA = {
36
+ type: 'FeatureCollection',
37
+ features: [],
38
+ };
39
+
40
+ const LAYER_ID_GEOJSON = 'selection-geojson';
41
+
42
+ const PASS_THROUGH_PROPS = [
43
+ 'lineWidthScale',
44
+ 'lineWidthMinPixels',
45
+ 'lineWidthMaxPixels',
46
+ 'lineWidthUnits',
47
+ 'lineJointRounded',
48
+ 'lineMiterLimit',
49
+ 'pointRadiusScale',
50
+ 'pointRadiusMinPixels',
51
+ 'pointRadiusMaxPixels',
52
+ 'lineDashJustified',
53
+ 'getLineColor',
54
+ 'getFillColor',
55
+ 'getPointRadius',
56
+ 'getLineWidth',
57
+ 'getLineDashArray',
58
+ 'getTentativeLineDashArray',
59
+ 'getTentativeLineColor',
60
+ 'getTentativeFillColor',
61
+ 'getTentativeLineWidth',
62
+ 'editHandlePointRadiusScale',
63
+ 'editHandlePointRadiusMinPixels',
64
+ 'editHandlePointRadiusMaxPixels',
65
+ 'getEditHandlePointColor',
66
+ 'getEditHandlePointRadius',
67
+ 'modeHandlers',
68
+ ];
69
+
70
+ export default class SelectionLayer extends CompositeLayer {
71
+ _selectPolygonObjects(coordinates) {
72
+ const {
73
+ onSelect,
74
+ getCellCoords,
75
+ cellsQuadTree,
76
+ flipY,
77
+ } = this.props;
78
+
79
+ const flippedCoordinates = (flipY
80
+ ? coordinates.map(poly => poly.map(p => ([p[0], -p[1]])))
81
+ : coordinates);
82
+
83
+ // Convert the selection to a turf polygon object.
84
+ const selectedPolygon = turfPolygon(flippedCoordinates);
85
+
86
+ // Create an array to store the results.
87
+ const pickingInfos = [];
88
+
89
+ // quadtree.visit() takes a callback that returns a boolean:
90
+ // If true returned, then the children of the node are _not_ visited.
91
+ // If false returned, then the children of the node are visited.
92
+ // Reference: https://github.com/d3/d3-quadtree#quadtree_visit
93
+ cellsQuadTree.visit((node, x0, y0, x1, y1) => {
94
+ const nodePoints = [[[x0, y0], [x1, y0], [x1, y1], [x0, y1], [x0, y0]]];
95
+ const nodePolygon = turfPolygon(nodePoints);
96
+
97
+ const nodePolygonContainsSelectedPolygon = booleanContains(nodePolygon, selectedPolygon);
98
+ const nodePolygonWithinSelectedPolygon = booleanWithin(nodePolygon, selectedPolygon);
99
+ const nodePolygonOverlapsSelectedPolgyon = booleanOverlap(nodePolygon, selectedPolygon);
100
+
101
+ if (!nodePolygonContainsSelectedPolygon
102
+ && !nodePolygonWithinSelectedPolygon
103
+ && !nodePolygonOverlapsSelectedPolgyon) {
104
+ // We are not interested in anything below this node,
105
+ // so return true because we are done with this node.
106
+ return true;
107
+ }
108
+
109
+ // This node made it past the above return statement, so it must either
110
+ // contain, be within, or overlap with the selected polygon.
111
+
112
+ // Check if this is a leaf node.
113
+ if (node.data
114
+ && booleanPointInPolygon(
115
+ turfPoint([].slice.call(getCellCoords(node.data))), selectedPolygon,
116
+ )
117
+ ) {
118
+ // This node has data, so it is a leaf node representing one data point,
119
+ // and we have verified that the point is in the selected polygon.
120
+ pickingInfos.push(node.data);
121
+ }
122
+
123
+ // Return false because we are not done.
124
+ // We want to visit the children of this node.
125
+ return false;
126
+ });
127
+
128
+ onSelect({ pickingInfos });
129
+ }
130
+
131
+ renderLayers() {
132
+ const { onSelect } = this.props;
133
+ const mode = MODE_MAP[this.props.selectionType] || ViewMode;
134
+
135
+ const inheritedProps = {};
136
+ PASS_THROUGH_PROPS.forEach((p) => {
137
+ if (this.props[p] !== undefined) inheritedProps[p] = this.props[p];
138
+ });
139
+ const layers = [
140
+ new EditableGeoJsonLayer(
141
+ this.getSubLayerProps({
142
+ id: LAYER_ID_GEOJSON,
143
+ pickable: true,
144
+ mode,
145
+ modeConfig: {
146
+ dragToDraw: true,
147
+ },
148
+ selectedFeatureIndexes: [],
149
+ data: EMPTY_DATA,
150
+ onEdit: ({ updatedData, editType }) => {
151
+ if (editType === EDIT_TYPE_ADD) {
152
+ const { coordinates } = updatedData.features[0].geometry;
153
+ this._selectPolygonObjects(coordinates);
154
+ } else if (editType === EDIT_TYPE_CLEAR) {
155
+ // We want to select an empty array to clear any previous selection.
156
+ onSelect({ pickingInfos: [] });
157
+ }
158
+ },
159
+ _subLayerProps: {
160
+ guides: {
161
+ pointType: 'circle',
162
+ _subLayerProps: {
163
+ 'points-circle': {
164
+ // Styling for editHandles goes here.
165
+ // Reference: https://github.com/uber/nebula.gl/issues/618#issuecomment-898466319
166
+ type: ScatterplotLayer,
167
+ radiusScale: 1,
168
+ stroked: true,
169
+ getLineWidth: 1,
170
+ radiusMinPixels: 1,
171
+ radiusMaxPixels: 3,
172
+ getPointRadius: 2,
173
+ },
174
+ },
175
+ },
176
+ },
177
+ ...inheritedProps,
178
+ }),
179
+ ),
180
+ ];
181
+
182
+ return layers;
183
+ }
184
+ }
185
+
186
+ SelectionLayer.layerName = 'SelectionLayer';
187
+ SelectionLayer.defaultProps = defaultProps;
@@ -0,0 +1,92 @@
1
+ import { colormaps } from './glsl/index.js';
2
+
3
+ export const vs = `
4
+ #define SHADER_NAME bitmask-layer-vertex-shader
5
+
6
+ attribute vec2 texCoords;
7
+ attribute vec3 positions;
8
+ attribute vec3 positions64Low;
9
+ attribute vec3 instancePickingColors;
10
+
11
+ varying vec2 vTexCoord;
12
+
13
+ void main(void) {
14
+ geometry.worldPosition = positions;
15
+ geometry.uv = texCoords;
16
+ geometry.pickingColor = instancePickingColors;
17
+ gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
18
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
19
+ vTexCoord = texCoords;
20
+ vec4 color = vec4(0.0);
21
+ DECKGL_FILTER_COLOR(color, geometry);
22
+ }
23
+ `;
24
+
25
+ export const fs = `
26
+ #define SHADER_NAME bitmask-layer-fragment-shader
27
+ precision highp float;
28
+
29
+ ${colormaps}
30
+
31
+ // Data (mask) texture
32
+ uniform sampler2D channel0;
33
+ uniform sampler2D channel1;
34
+ uniform sampler2D channel2;
35
+ uniform sampler2D channel3;
36
+ uniform sampler2D channel4;
37
+ uniform sampler2D channel5;
38
+
39
+ // Color texture
40
+ uniform sampler2D colorTex;
41
+ uniform float colorTexHeight;
42
+ uniform float colorTexWidth;
43
+ uniform float hovered;
44
+ // range
45
+ uniform bool channelsVisible[6];
46
+
47
+ // Expression mapping
48
+ uniform vec2 uColorScaleRange;
49
+ uniform bool uIsExpressionMode;
50
+ uniform sampler2D expressionTex;
51
+
52
+ // opacity
53
+ uniform float opacity;
54
+
55
+ varying vec2 vTexCoord;
56
+
57
+ vec4 sampleAndGetColor(sampler2D dataTex, vec2 coord, bool isOn){
58
+ float sampledData = texture(dataTex, coord).r;
59
+ vec4 hoveredColor = float(sampledData == hovered && sampledData > 0. && hovered > 0.) * vec4(0., 0., 1., 1.);
60
+ // Colors are laid out corresponding to ids in row-major order in the texture. So if width of the texture is 10, and you want ID 25,
61
+ // you need coordinate (1, 4) (i.e 2 rows down, and 5 columns over indexed from 0 for a total of 25 units covered in row major order).
62
+ vec2 colorTexCoord = vec2(mod(sampledData, colorTexWidth) / colorTexWidth, floor(sampledData / colorTexWidth) / (colorTexHeight - 1.));
63
+ float expressionValue = texture(expressionTex, colorTexCoord).r / 255.;
64
+ float scaledExpressionValue = (expressionValue - uColorScaleRange[0]) / max(0.005, (uColorScaleRange[1] - uColorScaleRange[0]));
65
+ vec4 sampledColor = float(uIsExpressionMode) * COLORMAP_FUNC(clamp(scaledExpressionValue, 0.0, 1.0)) + (1. - float(uIsExpressionMode)) * vec4(texture(colorTex, colorTexCoord).rgb, 1.);
66
+ // Only return a color if the data is non-zero.
67
+ return max(0., min(sampledData, 1.)) * float(isOn) * (sampledColor + hoveredColor);
68
+ }
69
+
70
+ void main() {
71
+
72
+ gl_FragColor = sampleAndGetColor(channel0, vTexCoord, channelsVisible[0]);
73
+
74
+ // If the sampled color and the currently stored color (gl_FragColor) are identical, don't blend and use the sampled color,
75
+ // otherwise just use the currently stored color. Repeat this for all channels.
76
+ vec4 sampledColor = sampleAndGetColor(channel1, vTexCoord, channelsVisible[1]);
77
+ gl_FragColor = (sampledColor == gl_FragColor || sampledColor == vec4(0.)) ? gl_FragColor : sampledColor;
78
+ sampledColor = sampleAndGetColor(channel2, vTexCoord, channelsVisible[2]);
79
+ gl_FragColor = (sampledColor == gl_FragColor || sampledColor == vec4(0.)) ? gl_FragColor : sampledColor;
80
+ sampledColor = sampleAndGetColor(channel3, vTexCoord, channelsVisible[3]);
81
+ gl_FragColor = (sampledColor == gl_FragColor || sampledColor == vec4(0.)) ? gl_FragColor : sampledColor;
82
+ sampledColor = sampleAndGetColor(channel4, vTexCoord, channelsVisible[4]);
83
+ gl_FragColor = (sampledColor == gl_FragColor || sampledColor == vec4(0.)) ? gl_FragColor : sampledColor;
84
+ sampledColor = sampleAndGetColor(channel5, vTexCoord, channelsVisible[5]);
85
+ gl_FragColor = (sampledColor == gl_FragColor || sampledColor == vec4(0.)) ? gl_FragColor : sampledColor;
86
+ // Apply the opacity if there is pixel data, and if the pixel data is empty i.e no segmentation, use 0 opacity.
87
+ gl_FragColor = vec4(gl_FragColor.rgb, (gl_FragColor.rgb == vec3(0., 0., 0.)) ? 0.0 : opacity);
88
+
89
+ geometry.uv = vTexCoord;
90
+ DECKGL_FILTER_COLOR(gl_FragColor, geometry);
91
+ }
92
+ `;
@@ -0,0 +1,13 @@
1
+ // List of the GLSL colormaps available,
2
+ // to validate against before string replacing.
3
+ export const GLSL_COLORMAPS = [
4
+ 'plasma',
5
+ 'viridis',
6
+ 'jet',
7
+ ];
8
+ export const GLSL_COLORMAP_DEFAULT = 'plasma';
9
+ export const COLORMAP_SHADER_PLACEHOLDER = 'COLORMAP_FUNC';
10
+
11
+ export const DEFAULT_GL_OPTIONS = { webgl2: true };
12
+
13
+ export { SELECTION_TYPE } from 'nebula.gl';
package/src/deck.js ADDED
@@ -0,0 +1,4 @@
1
+ export { default as DeckGL } from 'deck.gl';
2
+ export { COORDINATE_SYSTEM } from '@deck.gl/core';
3
+ export { PolygonLayer, TextLayer, ScatterplotLayer } from '@deck.gl/layers';
4
+ export { OrthographicView, OrbitView } from '@deck.gl/core';
@@ -0,0 +1,8 @@
1
+ The `.out.glsl` files in this directory must be generated by running
2
+
3
+ ```sh
4
+ pnpm run glslify
5
+ ```
6
+ in the root of the package.
7
+
8
+ Then, the outputs can be copied into JS files and exported.
@@ -0,0 +1,15 @@
1
+ #pragma glslify: plasma = require("glsl-colormap/plasma")
2
+ #pragma glslify: viridis = require("glsl-colormap/viridis")
3
+ #pragma glslify: greys = require("glsl-colormap/greys")
4
+ #pragma glslify: magma = require("glsl-colormap/magma")
5
+ #pragma glslify: jet = require("glsl-colormap/jet")
6
+ #pragma glslify: bone = require("glsl-colormap/bone")
7
+ #pragma glslify: copper = require("glsl-colormap/copper")
8
+ #pragma glslify: density = require("glsl-colormap/density")
9
+ #pragma glslify: inferno = require("glsl-colormap/inferno")
10
+ #pragma glslify: cool = require("glsl-colormap/cool")
11
+ #pragma glslify: hot = require("glsl-colormap/hot")
12
+ #pragma glslify: spring = require("glsl-colormap/spring")
13
+ #pragma glslify: summer = require("glsl-colormap/summer")
14
+ #pragma glslify: autumn = require("glsl-colormap/autumn")
15
+ #pragma glslify: winter = require("glsl-colormap/winter")
@@ -0,0 +1,341 @@
1
+
2
+ export const colormaps = `#define GLSLIFY 1
3
+ vec4 plasma (float x_4) {
4
+ const float e0 = 0.0;
5
+ const vec4 v0 = vec4(0.050980392156862744,0.03137254901960784,0.5294117647058824,1);
6
+ const float e1 = 0.13;
7
+ const vec4 v1 = vec4(0.29411764705882354,0.011764705882352941,0.6313725490196078,1);
8
+ const float e2 = 0.25;
9
+ const vec4 v2 = vec4(0.49019607843137253,0.011764705882352941,0.6588235294117647,1);
10
+ const float e3 = 0.38;
11
+ const vec4 v3 = vec4(0.6588235294117647,0.13333333333333333,0.5882352941176471,1);
12
+ const float e4 = 0.5;
13
+ const vec4 v4 = vec4(0.796078431372549,0.27450980392156865,0.4745098039215686,1);
14
+ const float e5 = 0.63;
15
+ const vec4 v5 = vec4(0.8980392156862745,0.4196078431372549,0.36470588235294116,1);
16
+ const float e6 = 0.75;
17
+ const vec4 v6 = vec4(0.9725490196078431,0.5803921568627451,0.2549019607843137,1);
18
+ const float e7 = 0.88;
19
+ const vec4 v7 = vec4(0.9921568627450981,0.7647058823529411,0.1568627450980392,1);
20
+ const float e8 = 1.0;
21
+ const vec4 v8 = vec4(0.9411764705882353,0.9764705882352941,0.12941176470588237,1);
22
+ float a0 = smoothstep(e0,e1,x_4);
23
+ float a1 = smoothstep(e1,e2,x_4);
24
+ float a2 = smoothstep(e2,e3,x_4);
25
+ float a3 = smoothstep(e3,e4,x_4);
26
+ float a4 = smoothstep(e4,e5,x_4);
27
+ float a5 = smoothstep(e5,e6,x_4);
28
+ float a6 = smoothstep(e6,e7,x_4);
29
+ float a7 = smoothstep(e7,e8,x_4);
30
+ return max(mix(v0,v1,a0)*step(e0,x_4)*step(x_4,e1),
31
+ max(mix(v1,v2,a1)*step(e1,x_4)*step(x_4,e2),
32
+ max(mix(v2,v3,a2)*step(e2,x_4)*step(x_4,e3),
33
+ max(mix(v3,v4,a3)*step(e3,x_4)*step(x_4,e4),
34
+ max(mix(v4,v5,a4)*step(e4,x_4)*step(x_4,e5),
35
+ max(mix(v5,v6,a5)*step(e5,x_4)*step(x_4,e6),
36
+ max(mix(v6,v7,a6)*step(e6,x_4)*step(x_4,e7),mix(v7,v8,a7)*step(e7,x_4)*step(x_4,e8)
37
+ )))))));
38
+ }
39
+
40
+ vec4 viridis (float x_1) {
41
+ const float e0 = 0.0;
42
+ const vec4 v0 = vec4(0.26666666666666666,0.00392156862745098,0.32941176470588235,1);
43
+ const float e1 = 0.13;
44
+ const vec4 v1 = vec4(0.2784313725490196,0.17254901960784313,0.47843137254901963,1);
45
+ const float e2 = 0.25;
46
+ const vec4 v2 = vec4(0.23137254901960785,0.3176470588235294,0.5450980392156862,1);
47
+ const float e3 = 0.38;
48
+ const vec4 v3 = vec4(0.17254901960784313,0.44313725490196076,0.5568627450980392,1);
49
+ const float e4 = 0.5;
50
+ const vec4 v4 = vec4(0.12941176470588237,0.5647058823529412,0.5529411764705883,1);
51
+ const float e5 = 0.63;
52
+ const vec4 v5 = vec4(0.15294117647058825,0.6784313725490196,0.5058823529411764,1);
53
+ const float e6 = 0.75;
54
+ const vec4 v6 = vec4(0.3607843137254902,0.7843137254901961,0.38823529411764707,1);
55
+ const float e7 = 0.88;
56
+ const vec4 v7 = vec4(0.6666666666666666,0.8627450980392157,0.19607843137254902,1);
57
+ const float e8 = 1.0;
58
+ const vec4 v8 = vec4(0.9921568627450981,0.9058823529411765,0.1450980392156863,1);
59
+ float a0 = smoothstep(e0,e1,x_1);
60
+ float a1 = smoothstep(e1,e2,x_1);
61
+ float a2 = smoothstep(e2,e3,x_1);
62
+ float a3 = smoothstep(e3,e4,x_1);
63
+ float a4 = smoothstep(e4,e5,x_1);
64
+ float a5 = smoothstep(e5,e6,x_1);
65
+ float a6 = smoothstep(e6,e7,x_1);
66
+ float a7 = smoothstep(e7,e8,x_1);
67
+ return max(mix(v0,v1,a0)*step(e0,x_1)*step(x_1,e1),
68
+ max(mix(v1,v2,a1)*step(e1,x_1)*step(x_1,e2),
69
+ max(mix(v2,v3,a2)*step(e2,x_1)*step(x_1,e3),
70
+ max(mix(v3,v4,a3)*step(e3,x_1)*step(x_1,e4),
71
+ max(mix(v4,v5,a4)*step(e4,x_1)*step(x_1,e5),
72
+ max(mix(v5,v6,a5)*step(e5,x_1)*step(x_1,e6),
73
+ max(mix(v6,v7,a6)*step(e6,x_1)*step(x_1,e7),mix(v7,v8,a7)*step(e7,x_1)*step(x_1,e8)
74
+ )))))));
75
+ }
76
+
77
+ vec4 greys (float x_10) {
78
+ const float e0 = 0.0;
79
+ const vec4 v0 = vec4(0,0,0,1);
80
+ const float e1 = 1.0;
81
+ const vec4 v1 = vec4(1,1,1,1);
82
+ float a0 = smoothstep(e0,e1,x_10);
83
+ return mix(v0,v1,a0)*step(e0,x_10)*step(x_10,e1);
84
+ }
85
+
86
+ vec4 magma (float x_7) {
87
+ const float e0 = 0.0;
88
+ const vec4 v0 = vec4(0,0,0.01568627450980392,1);
89
+ const float e1 = 0.13;
90
+ const vec4 v1 = vec4(0.10980392156862745,0.06274509803921569,0.26666666666666666,1);
91
+ const float e2 = 0.25;
92
+ const vec4 v2 = vec4(0.30980392156862746,0.07058823529411765,0.4823529411764706,1);
93
+ const float e3 = 0.38;
94
+ const vec4 v3 = vec4(0.5058823529411764,0.1450980392156863,0.5058823529411764,1);
95
+ const float e4 = 0.5;
96
+ const vec4 v4 = vec4(0.7098039215686275,0.21176470588235294,0.47843137254901963,1);
97
+ const float e5 = 0.63;
98
+ const vec4 v5 = vec4(0.8980392156862745,0.3137254901960784,0.39215686274509803,1);
99
+ const float e6 = 0.75;
100
+ const vec4 v6 = vec4(0.984313725490196,0.5294117647058824,0.3803921568627451,1);
101
+ const float e7 = 0.88;
102
+ const vec4 v7 = vec4(0.996078431372549,0.7607843137254902,0.5294117647058824,1);
103
+ const float e8 = 1.0;
104
+ const vec4 v8 = vec4(0.9882352941176471,0.9921568627450981,0.7490196078431373,1);
105
+ float a0 = smoothstep(e0,e1,x_7);
106
+ float a1 = smoothstep(e1,e2,x_7);
107
+ float a2 = smoothstep(e2,e3,x_7);
108
+ float a3 = smoothstep(e3,e4,x_7);
109
+ float a4 = smoothstep(e4,e5,x_7);
110
+ float a5 = smoothstep(e5,e6,x_7);
111
+ float a6 = smoothstep(e6,e7,x_7);
112
+ float a7 = smoothstep(e7,e8,x_7);
113
+ return max(mix(v0,v1,a0)*step(e0,x_7)*step(x_7,e1),
114
+ max(mix(v1,v2,a1)*step(e1,x_7)*step(x_7,e2),
115
+ max(mix(v2,v3,a2)*step(e2,x_7)*step(x_7,e3),
116
+ max(mix(v3,v4,a3)*step(e3,x_7)*step(x_7,e4),
117
+ max(mix(v4,v5,a4)*step(e4,x_7)*step(x_7,e5),
118
+ max(mix(v5,v6,a5)*step(e5,x_7)*step(x_7,e6),
119
+ max(mix(v6,v7,a6)*step(e6,x_7)*step(x_7,e7),mix(v7,v8,a7)*step(e7,x_7)*step(x_7,e8)
120
+ )))))));
121
+ }
122
+
123
+ vec4 jet (float x_8) {
124
+ const float e0 = 0.0;
125
+ const vec4 v0 = vec4(0,0,0.5137254901960784,1);
126
+ const float e1 = 0.125;
127
+ const vec4 v1 = vec4(0,0.23529411764705882,0.6666666666666666,1);
128
+ const float e2 = 0.375;
129
+ const vec4 v2 = vec4(0.0196078431372549,1,1,1);
130
+ const float e3 = 0.625;
131
+ const vec4 v3 = vec4(1,1,0,1);
132
+ const float e4 = 0.875;
133
+ const vec4 v4 = vec4(0.9803921568627451,0,0,1);
134
+ const float e5 = 1.0;
135
+ const vec4 v5 = vec4(0.5019607843137255,0,0,1);
136
+ float a0 = smoothstep(e0,e1,x_8);
137
+ float a1 = smoothstep(e1,e2,x_8);
138
+ float a2 = smoothstep(e2,e3,x_8);
139
+ float a3 = smoothstep(e3,e4,x_8);
140
+ float a4 = smoothstep(e4,e5,x_8);
141
+ return max(mix(v0,v1,a0)*step(e0,x_8)*step(x_8,e1),
142
+ max(mix(v1,v2,a1)*step(e1,x_8)*step(x_8,e2),
143
+ max(mix(v2,v3,a2)*step(e2,x_8)*step(x_8,e3),
144
+ max(mix(v3,v4,a3)*step(e3,x_8)*step(x_8,e4),mix(v4,v5,a4)*step(e4,x_8)*step(x_8,e5)
145
+ ))));
146
+ }
147
+
148
+ vec4 bone (float x_11) {
149
+ const float e0 = 0.0;
150
+ const vec4 v0 = vec4(0,0,0,1);
151
+ const float e1 = 0.376;
152
+ const vec4 v1 = vec4(0.32941176470588235,0.32941176470588235,0.4549019607843137,1);
153
+ const float e2 = 0.753;
154
+ const vec4 v2 = vec4(0.6627450980392157,0.7843137254901961,0.7843137254901961,1);
155
+ const float e3 = 1.0;
156
+ const vec4 v3 = vec4(1,1,1,1);
157
+ float a0 = smoothstep(e0,e1,x_11);
158
+ float a1 = smoothstep(e1,e2,x_11);
159
+ float a2 = smoothstep(e2,e3,x_11);
160
+ return max(mix(v0,v1,a0)*step(e0,x_11)*step(x_11,e1),
161
+ max(mix(v1,v2,a1)*step(e1,x_11)*step(x_11,e2),mix(v2,v3,a2)*step(e2,x_11)*step(x_11,e3)
162
+ ));
163
+ }
164
+
165
+ vec4 copper (float x_6) {
166
+ const float e0 = 0.0;
167
+ const vec4 v0 = vec4(0,0,0,1);
168
+ const float e1 = 0.804;
169
+ const vec4 v1 = vec4(1,0.6274509803921569,0.4,1);
170
+ const float e2 = 1.0;
171
+ const vec4 v2 = vec4(1,0.7803921568627451,0.4980392156862745,1);
172
+ float a0 = smoothstep(e0,e1,x_6);
173
+ float a1 = smoothstep(e1,e2,x_6);
174
+ return max(mix(v0,v1,a0)*step(e0,x_6)*step(x_6,e1),mix(v1,v2,a1)*step(e1,x_6)*step(x_6,e2)
175
+ );
176
+ }
177
+
178
+ vec4 density (float x_5) {
179
+ const float e0 = 0.0;
180
+ const vec4 v0 = vec4(0.21176470588235294,0.054901960784313725,0.1411764705882353,1);
181
+ const float e1 = 0.13;
182
+ const vec4 v1 = vec4(0.34901960784313724,0.09019607843137255,0.3137254901960784,1);
183
+ const float e2 = 0.25;
184
+ const vec4 v2 = vec4(0.43137254901960786,0.17647058823529413,0.5176470588235295,1);
185
+ const float e3 = 0.38;
186
+ const vec4 v3 = vec4(0.47058823529411764,0.30196078431372547,0.6980392156862745,1);
187
+ const float e4 = 0.5;
188
+ const vec4 v4 = vec4(0.47058823529411764,0.44313725490196076,0.8352941176470589,1);
189
+ const float e5 = 0.63;
190
+ const vec4 v5 = vec4(0.45098039215686275,0.592156862745098,0.8941176470588236,1);
191
+ const float e6 = 0.75;
192
+ const vec4 v6 = vec4(0.5254901960784314,0.7254901960784313,0.8901960784313725,1);
193
+ const float e7 = 0.88;
194
+ const vec4 v7 = vec4(0.6941176470588235,0.8392156862745098,0.8901960784313725,1);
195
+ const float e8 = 1.0;
196
+ const vec4 v8 = vec4(0.9019607843137255,0.9450980392156862,0.9450980392156862,1);
197
+ float a0 = smoothstep(e0,e1,x_5);
198
+ float a1 = smoothstep(e1,e2,x_5);
199
+ float a2 = smoothstep(e2,e3,x_5);
200
+ float a3 = smoothstep(e3,e4,x_5);
201
+ float a4 = smoothstep(e4,e5,x_5);
202
+ float a5 = smoothstep(e5,e6,x_5);
203
+ float a6 = smoothstep(e6,e7,x_5);
204
+ float a7 = smoothstep(e7,e8,x_5);
205
+ return max(mix(v0,v1,a0)*step(e0,x_5)*step(x_5,e1),
206
+ max(mix(v1,v2,a1)*step(e1,x_5)*step(x_5,e2),
207
+ max(mix(v2,v3,a2)*step(e2,x_5)*step(x_5,e3),
208
+ max(mix(v3,v4,a3)*step(e3,x_5)*step(x_5,e4),
209
+ max(mix(v4,v5,a4)*step(e4,x_5)*step(x_5,e5),
210
+ max(mix(v5,v6,a5)*step(e5,x_5)*step(x_5,e6),
211
+ max(mix(v6,v7,a6)*step(e6,x_5)*step(x_5,e7),mix(v7,v8,a7)*step(e7,x_5)*step(x_5,e8)
212
+ )))))));
213
+ }
214
+
215
+ vec4 inferno (float x_3) {
216
+ const float e0 = 0.0;
217
+ const vec4 v0 = vec4(0,0,0.01568627450980392,1);
218
+ const float e1 = 0.13;
219
+ const vec4 v1 = vec4(0.12156862745098039,0.047058823529411764,0.2823529411764706,1);
220
+ const float e2 = 0.25;
221
+ const vec4 v2 = vec4(0.3333333333333333,0.058823529411764705,0.42745098039215684,1);
222
+ const float e3 = 0.38;
223
+ const vec4 v3 = vec4(0.5333333333333333,0.13333333333333333,0.41568627450980394,1);
224
+ const float e4 = 0.5;
225
+ const vec4 v4 = vec4(0.7294117647058823,0.21176470588235294,0.3333333333333333,1);
226
+ const float e5 = 0.63;
227
+ const vec4 v5 = vec4(0.8901960784313725,0.34901960784313724,0.2,1);
228
+ const float e6 = 0.75;
229
+ const vec4 v6 = vec4(0.9764705882352941,0.5490196078431373,0.0392156862745098,1);
230
+ const float e7 = 0.88;
231
+ const vec4 v7 = vec4(0.9764705882352941,0.788235294117647,0.19607843137254902,1);
232
+ const float e8 = 1.0;
233
+ const vec4 v8 = vec4(0.9882352941176471,1,0.6431372549019608,1);
234
+ float a0 = smoothstep(e0,e1,x_3);
235
+ float a1 = smoothstep(e1,e2,x_3);
236
+ float a2 = smoothstep(e2,e3,x_3);
237
+ float a3 = smoothstep(e3,e4,x_3);
238
+ float a4 = smoothstep(e4,e5,x_3);
239
+ float a5 = smoothstep(e5,e6,x_3);
240
+ float a6 = smoothstep(e6,e7,x_3);
241
+ float a7 = smoothstep(e7,e8,x_3);
242
+ return max(mix(v0,v1,a0)*step(e0,x_3)*step(x_3,e1),
243
+ max(mix(v1,v2,a1)*step(e1,x_3)*step(x_3,e2),
244
+ max(mix(v2,v3,a2)*step(e2,x_3)*step(x_3,e3),
245
+ max(mix(v3,v4,a3)*step(e3,x_3)*step(x_3,e4),
246
+ max(mix(v4,v5,a4)*step(e4,x_3)*step(x_3,e5),
247
+ max(mix(v5,v6,a5)*step(e5,x_3)*step(x_3,e6),
248
+ max(mix(v6,v7,a6)*step(e6,x_3)*step(x_3,e7),mix(v7,v8,a7)*step(e7,x_3)*step(x_3,e8)
249
+ )))))));
250
+ }
251
+
252
+ vec4 cool (float x_2) {
253
+ const float e0 = 0.0;
254
+ const vec4 v0 = vec4(0.49019607843137253,0,0.7019607843137254,1);
255
+ const float e1 = 0.13;
256
+ const vec4 v1 = vec4(0.4549019607843137,0,0.8549019607843137,1);
257
+ const float e2 = 0.25;
258
+ const vec4 v2 = vec4(0.3843137254901961,0.2901960784313726,0.9294117647058824,1);
259
+ const float e3 = 0.38;
260
+ const vec4 v3 = vec4(0.26666666666666666,0.5725490196078431,0.9058823529411765,1);
261
+ const float e4 = 0.5;
262
+ const vec4 v4 = vec4(0,0.8,0.7725490196078432,1);
263
+ const float e5 = 0.63;
264
+ const vec4 v5 = vec4(0,0.9686274509803922,0.5725490196078431,1);
265
+ const float e6 = 0.75;
266
+ const vec4 v6 = vec4(0,1,0.34509803921568627,1);
267
+ const float e7 = 0.88;
268
+ const vec4 v7 = vec4(0.1568627450980392,1,0.03137254901960784,1);
269
+ const float e8 = 1.0;
270
+ const vec4 v8 = vec4(0.5764705882352941,1,0,1);
271
+ float a0 = smoothstep(e0,e1,x_2);
272
+ float a1 = smoothstep(e1,e2,x_2);
273
+ float a2 = smoothstep(e2,e3,x_2);
274
+ float a3 = smoothstep(e3,e4,x_2);
275
+ float a4 = smoothstep(e4,e5,x_2);
276
+ float a5 = smoothstep(e5,e6,x_2);
277
+ float a6 = smoothstep(e6,e7,x_2);
278
+ float a7 = smoothstep(e7,e8,x_2);
279
+ return max(mix(v0,v1,a0)*step(e0,x_2)*step(x_2,e1),
280
+ max(mix(v1,v2,a1)*step(e1,x_2)*step(x_2,e2),
281
+ max(mix(v2,v3,a2)*step(e2,x_2)*step(x_2,e3),
282
+ max(mix(v3,v4,a3)*step(e3,x_2)*step(x_2,e4),
283
+ max(mix(v4,v5,a4)*step(e4,x_2)*step(x_2,e5),
284
+ max(mix(v5,v6,a5)*step(e5,x_2)*step(x_2,e6),
285
+ max(mix(v6,v7,a6)*step(e6,x_2)*step(x_2,e7),mix(v7,v8,a7)*step(e7,x_2)*step(x_2,e8)
286
+ )))))));
287
+ }
288
+
289
+ vec4 hot (float x_0) {
290
+ const float e0 = 0.0;
291
+ const vec4 v0 = vec4(0,0,0,1);
292
+ const float e1 = 0.3;
293
+ const vec4 v1 = vec4(0.9019607843137255,0,0,1);
294
+ const float e2 = 0.6;
295
+ const vec4 v2 = vec4(1,0.8235294117647058,0,1);
296
+ const float e3 = 1.0;
297
+ const vec4 v3 = vec4(1,1,1,1);
298
+ float a0 = smoothstep(e0,e1,x_0);
299
+ float a1 = smoothstep(e1,e2,x_0);
300
+ float a2 = smoothstep(e2,e3,x_0);
301
+ return max(mix(v0,v1,a0)*step(e0,x_0)*step(x_0,e1),
302
+ max(mix(v1,v2,a1)*step(e1,x_0)*step(x_0,e2),mix(v2,v3,a2)*step(e2,x_0)*step(x_0,e3)
303
+ ));
304
+ }
305
+
306
+ vec4 spring (float x_14) {
307
+ const float e0 = 0.0;
308
+ const vec4 v0 = vec4(1,0,1,1);
309
+ const float e1 = 1.0;
310
+ const vec4 v1 = vec4(1,1,0,1);
311
+ float a0 = smoothstep(e0,e1,x_14);
312
+ return mix(v0,v1,a0)*step(e0,x_14)*step(x_14,e1);
313
+ }
314
+
315
+ vec4 summer (float x_9) {
316
+ const float e0 = 0.0;
317
+ const vec4 v0 = vec4(0,0.5019607843137255,0.4,1);
318
+ const float e1 = 1.0;
319
+ const vec4 v1 = vec4(1,1,0.4,1);
320
+ float a0 = smoothstep(e0,e1,x_9);
321
+ return mix(v0,v1,a0)*step(e0,x_9)*step(x_9,e1);
322
+ }
323
+
324
+ vec4 autumn (float x_13) {
325
+ const float e0 = 0.0;
326
+ const vec4 v0 = vec4(1,0,0,1);
327
+ const float e1 = 1.0;
328
+ const vec4 v1 = vec4(1,1,0,1);
329
+ float a0 = smoothstep(e0,e1,x_13);
330
+ return mix(v0,v1,a0)*step(e0,x_13)*step(x_13,e1);
331
+ }
332
+
333
+ vec4 winter (float x_12) {
334
+ const float e0 = 0.0;
335
+ const vec4 v0 = vec4(0,0,1,1);
336
+ const float e1 = 1.0;
337
+ const vec4 v1 = vec4(0,1,0.5019607843137255,1);
338
+ float a0 = smoothstep(e0,e1,x_12);
339
+ return mix(v0,v1,a0)*step(e0,x_12)*step(x_12,e1);
340
+ }
341
+ `;