Skip to content

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Sep 23, 2025

This is a refactor that originally came out of discussions with @ibgreen about a year ago. Currently, each layer here takes in an arrow.Table and will generate one underlying deck.gl layer per underlying RecordBatch. With this change, each layer now takes in an arrow.RecordBatch, and will render exactly one underlying layer (or maybe two, in the case of PolygonLayer which renders both a solid and an outline, but still, bounded).

  • This makes layer generation and overhead more predictable, as one underlying layer will always be created from the input. Whereas currently if a Table has 100 batches, 100 deck.gl layers will be generated under the hood, which might not be clear to the user.
  • This makes the layer implementation here simpler. We can remove the computation of "chunk offsets". Previously, for picking, if we received an integer index n, we'd have to backtrack to figure out which input batch is associated with that n. So if we had 10 batches of 10 rows each, when n is 95 the row would be coming from the last batch of the table. Now this is removed from the layer internals.
  • This means the user now has to iterate through the batches of a Table themselves to, generating an independent layer for each batch. This also means that the user has to remember to assign a unique id to each layer, such as by concatenating the record batch index to the primary id.

Change list

  • Update all layer types and props to use contiguous buffers as input. That means arrow.Data instead of arrow.Vector and arrow.RecordBatch instead of arrow.Table.

  • Try to update the geoarrow.point example, though this is currently failing with

     Uncaught (in promise) Error: Error during linking: Vertex shader is not compiled.
    

    I'm probably doing something wrong, maybe in my bundling setup.

@felixpalmer
Copy link

Try setting luma.log.level = 3 in the console to see if it is gives you the actual error that prevented compilation

@kylebarron
Copy link
Member Author


MapLibre | © CARTO, © OpenStreetMap contributors

Shader Compilation Error in vertex scatterplot-layer-vertex-shader


   1: #version 300 es
   2: 
   3: // ----- PROLOGUE -------------------------
   4: 
   5: #define SHADER_TYPE_VERTEX
   6: 
   7: #define APPLE_GPU
   8: // Apple optimizes away the calculation necessary for emulated fp64
   9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
  10: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
  11: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
  12: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
  13: 
  14: 
  15: 
  16: // ----- APPLICATION DEFINES -------------------------
  17: 
  18: 
  19: 
  20: // ----- MODULE fp32 ---------------
  21: 
  22: #define MODULE_FP32
  23: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
  24: 
  25: // All these functions are for substituting tan() function from Intel GPU only
  26: const float TWO_PI = 6.2831854820251465;
  27: const float PI_2 = 1.5707963705062866;
  28: const float PI_16 = 0.1963495463132858;
  29: 
  30: const float SIN_TABLE_0 = 0.19509032368659973;
  31: const float SIN_TABLE_1 = 0.3826834261417389;
  32: const float SIN_TABLE_2 = 0.5555702447891235;
  33: const float SIN_TABLE_3 = 0.7071067690849304;
  34: 
  35: const float COS_TABLE_0 = 0.9807852506637573;
  36: const float COS_TABLE_1 = 0.9238795042037964;
  37: const float COS_TABLE_2 = 0.8314695954322815;
  38: const float COS_TABLE_3 = 0.7071067690849304;
  39: 
  40: const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!
  41: const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!
  42: const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
  43: const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!
  44: 
  45: float sin_taylor_fp32(float a) {
  46:   float r, s, t, x;
  47: 
  48:   if (a == 0.0) {
  49:     return 0.0;
  50:   }
  51: 
  52:   x = -a * a;
  53:   s = a;
  54:   r = a;
  55: 
  56:   r = r * x;
  57:   t = r * INVERSE_FACTORIAL_3;
  58:   s = s + t;
  59: 
  60:   r = r * x;
  61:   t = r * INVERSE_FACTORIAL_5;
  62:   s = s + t;
  63: 
  64:   r = r * x;
  65:   t = r * INVERSE_FACTORIAL_7;
  66:   s = s + t;
  67: 
  68:   r = r * x;
  69:   t = r * INVERSE_FACTORIAL_9;
  70:   s = s + t;
  71: 
  72:   return s;
  73: }
  74: 
  75: void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {
  76:   if (a == 0.0) {
  77:     sin_t = 0.0;
  78:     cos_t = 1.0;
  79:   }
  80:   sin_t = sin_taylor_fp32(a);
  81:   cos_t = sqrt(1.0 - sin_t * sin_t);
  82: }
  83: 
  84: float tan_taylor_fp32(float a) {
  85:     float sin_a;
  86:     float cos_a;
  87: 
  88:     if (a == 0.0) {
  89:         return 0.0;
  90:     }
  91: 
  92:     // 2pi range reduction
  93:     float z = floor(a / TWO_PI);
  94:     float r = a - TWO_PI * z;
  95: 
  96:     float t;
  97:     float q = floor(r / PI_2 + 0.5);
  98:     int j = int(q);
  99: 
 100:     if (j < -2 || j > 2) {
 101:         return 1.0 / 0.0;
 WARNING: '/' : Divide by zero during constant folding
 102:     }
 103: 
 104:     t = r - PI_2 * q;
 105: 
 106:     q = floor(t / PI_16 + 0.5);
 107:     int k = int(q);
 108:     int abs_k = int(abs(float(k)));
 109: 
 110:     if (abs_k > 4) {
 111:         return 1.0 / 0.0;
 WARNING: '/' : Divide by zero during constant folding
 112:     } else {
 113:         t = t - PI_16 * q;
 114:     }
 115: 
 116:     float u = 0.0;
 117:     float v = 0.0;
 118: 
 119:     float sin_t, cos_t;
 120:     float s, c;
 121:     sincos_taylor_fp32(t, sin_t, cos_t);
 122: 
 123:     if (k == 0) {
 124:         s = sin_t;
 125:         c = cos_t;
 126:     } else {
 127:         if (abs(float(abs_k) - 1.0) < 0.5) {
 128:             u = COS_TABLE_0;
 129:             v = SIN_TABLE_0;
 130:         } else if (abs(float(abs_k) - 2.0) < 0.5) {
 131:             u = COS_TABLE_1;
 132:             v = SIN_TABLE_1;
 133:         } else if (abs(float(abs_k) - 3.0) < 0.5) {
 134:             u = COS_TABLE_2;
 135:             v = SIN_TABLE_2;
 136:         } else if (abs(float(abs_k) - 4.0) < 0.5) {
 137:             u = COS_TABLE_3;
 138:             v = SIN_TABLE_3;
 139:         }
 140:         if (k > 0) {
 141:             s = u * sin_t + v * cos_t;
 142:             c = u * cos_t - v * sin_t;
 143:         } else {
 144:             s = u * sin_t - v * cos_t;
 145:             c = u * cos_t + v * sin_t;
 146:         }
 147:     }
 148: 
 149:     if (j == 0) {
 150:         sin_a = s;
 151:         cos_a = c;
 152:     } else if (j == 1) {
 153:         sin_a = c;
 154:         cos_a = -s;
 155:     } else if (j == -1) {
 156:         sin_a = -c;
 157:         cos_a = s;
 158:     } else {
 159:         sin_a = -s;
 160:         cos_a = -c;
 161:     }
 162:     return sin_a / cos_a;
 163: }
 164: #endif
 165: 
 166: float tan_fp32(float a) {
 167: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
 168:   return tan_taylor_fp32(a);
 169: #else
 170:   return tan(a);
 171: #endif
 172: }
 173: 
 174: // ----- MODULE geometry ---------------
 175: 
 176: #define MODULE_GEOMETRY
 177: #define SMOOTH_EDGE_RADIUS 0.5
 178: 
 179: struct VertexGeometry {
 180:   vec4 position;
 181:   vec3 worldPosition;
 182:   vec3 worldPositionAlt;
 183:   vec3 normal;
 184:   vec2 uv;
 185:   vec3 pickingColor;
 186: } geometry = VertexGeometry(
 187:   vec4(0.0, 0.0, 1.0, 0.0),
 188:   vec3(0.0),
 189:   vec3(0.0),
 190:   vec3(0.0),
 191:   vec2(0.0),
 192:   vec3(0.0)
 193: );
 194: 
 195: // ----- MODULE project ---------------
 196: 
 197: #define MODULE_PROJECT
 198: const int COORDINATE_SYSTEM_DEFAULT = -1;const int COORDINATE_SYSTEM_LNGLAT = 1;const int COORDINATE_SYSTEM_METER_OFFSETS = 2;const int COORDINATE_SYSTEM_LNGLAT_OFFSETS = 3;const int COORDINATE_SYSTEM_CARTESIAN = 0;
 199: const int PROJECTION_MODE_WEB_MERCATOR = 1;const int PROJECTION_MODE_GLOBE = 2;const int PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET = 4;const int PROJECTION_MODE_IDENTITY = 0;
 200: const int UNIT_COMMON = 0;const int UNIT_METERS = 1;const int UNIT_PIXELS = 2;
 201: uniform projectUniforms {
 202: bool wrapLongitude;
 203: int coordinateSystem;
 204: vec3 commonUnitsPerMeter;
 205: int projectionMode;
 206: float scale;
 207: vec3 commonUnitsPerWorldUnit;
 208: vec3 commonUnitsPerWorldUnit2;
 209: vec4 center;
 210: mat4 modelMatrix;
 211: mat4 viewProjectionMatrix;
 212: vec2 viewportSize;
 213: float devicePixelRatio;
 214: float focalDistance;
 215: vec3 cameraPosition;
 216: vec3 coordinateOrigin;
 217: vec3 commonOrigin;
 218: bool pseudoMeters;
 219: } project;
 220: const float TILE_SIZE = 512.0;
 221: const float PI = 3.1415926536;
 222: const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
 223: const vec3 ZERO_64_LOW = vec3(0.0);
 224: const float EARTH_RADIUS = 6370972.0;
 225: const float GLOBE_RADIUS = 256.0;
 226: float project_size_at_latitude(float lat) {
 227: float y = clamp(lat, -89.9, 89.9);
 228: return 1.0 / cos(radians(y));
 229: }
 230: float project_size() {
 231: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
 232: project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
 233: project.pseudoMeters == false) {
 234: if (geometry.position.w == 0.0) {
 235: return project_size_at_latitude(geometry.worldPosition.y);
 236: }
 237: float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
 238: float y2 = y * y;
 239: float y4 = y2 * y2;
 240: float y6 = y4 * y2;
 241: return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
 242: }
 243: return 1.0;
 244: }
 245: float project_size_at_latitude(float meters, float lat) {
 246: return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
 247: }
 248: float project_size(float meters) {
 249: return meters * project.commonUnitsPerMeter.z * project_size();
 250: }
 251: vec2 project_size(vec2 meters) {
 252: return meters * project.commonUnitsPerMeter.xy * project_size();
 253: }
 254: vec3 project_size(vec3 meters) {
 255: return meters * project.commonUnitsPerMeter * project_size();
 256: }
 257: vec4 project_size(vec4 meters) {
 258: return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
 259: }
 260: mat3 project_get_orientation_matrix(vec3 up) {
 261: vec3 uz = normalize(up);
 262: vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
 263: vec3 uy = cross(uz, ux);
 264: return mat3(ux, uy, uz);
 265: }
 266: bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
 267: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
 268: transform = project_get_orientation_matrix(commonPosition);
 269: return true;
 270: }
 271: return false;
 272: }
 273: vec3 project_normal(vec3 vector) {
 274: vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
 275: vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
 276: mat3 rotation;
 277: if (project_needs_rotation(geometry.position.xyz, rotation)) {
 278: n = rotation * n;
 279: }
 280: return n;
 281: }
 282: vec4 project_offset_(vec4 offset) {
 283: float dy = offset.y;
 284: vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
 285: return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
 286: }
 287: vec2 project_mercator_(vec2 lnglat) {
 288: float x = lnglat.x;
 289: if (project.wrapLongitude) {
 290: x = mod(x + 180., 360.0) - 180.;
 291: }
 292: float y = clamp(lnglat.y, -89.9, 89.9);
 293: return vec2(
 294: radians(x) + PI,
 295: PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
 296: ) * WORLD_SCALE;
 297: }
 298: vec3 project_globe_(vec3 lnglatz) {
 299: float lambda = radians(lnglatz.x);
 300: float phi = radians(lnglatz.y);
 301: float cosPhi = cos(phi);
 302: float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
 303: return vec3(
 304: sin(lambda) * cosPhi,
 305: -cos(lambda) * cosPhi,
 306: sin(phi)
 307: ) * D;
 308: }
 309: vec4 project_position(vec4 position, vec3 position64Low) {
 310: vec4 position_world = project.modelMatrix * position;
 311: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
 312: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 313: return vec4(
 314: project_mercator_(position_world.xy),
 315: project_size_at_latitude(position_world.z, position_world.y),
 316: position_world.w
 317: );
 318: }
 319: if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
 320: position_world.xyz += project.coordinateOrigin;
 321: }
 322: }
 323: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
 324: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 325: return vec4(
 326: project_globe_(position_world.xyz),
 327: position_world.w
 328: );
 329: }
 330: }
 331: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
 332: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 333: if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
 334: return vec4(
 335: project_mercator_(position_world.xy) - project.commonOrigin.xy,
 336: project_size(position_world.z),
 337: position_world.w
 338: );
 339: }
 340: }
 341: }
 342: if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
 343: (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
 344: (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
 345: project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
 346: position_world.xyz -= project.coordinateOrigin;
 347: }
 348: return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
 349: }
 350: vec4 project_position(vec4 position) {
 351: return project_position(position, ZERO_64_LOW);
 352: }
 353: vec3 project_position(vec3 position, vec3 position64Low) {
 354: vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
 355: return projected_position.xyz;
 356: }
 357: vec3 project_position(vec3 position) {
 358: vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
 359: return projected_position.xyz;
 360: }
 361: vec2 project_position(vec2 position) {
 362: vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
 363: return projected_position.xy;
 364: }
 365: vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
 366: return viewProjectionMatrix * position + center;
 367: }
 368: vec4 project_common_position_to_clipspace(vec4 position) {
 369: return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
 370: }
 371: vec2 project_pixel_size_to_clipspace(vec2 pixels) {
 372: vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
 373: return offset * project.focalDistance;
 374: }
 375: float project_size_to_pixel(float meters) {
 376: return project_size(meters) * project.scale;
 377: }
 378: float project_size_to_pixel(float size, int unit) {
 379: if (unit == UNIT_METERS) return project_size_to_pixel(size);
 380: if (unit == UNIT_COMMON) return size * project.scale;
 381: return size;
 382: }
 383: float project_pixel_size(float pixels) {
 384: return pixels / project.scale;
 385: }
 386: vec2 project_pixel_size(vec2 pixels) {
 387: return pixels / project.scale;
 388: }
 389: 
 390: // ----- MODULE project32 ---------------
 391: 
 392: #define MODULE_PROJECT32
 393: vec4 project_position_to_clipspace(
 394:   vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
 395: ) {
 396:   vec3 projectedPosition = project_position(position, position64Low);
 397:   mat3 rotation;
 398:   if (project_needs_rotation(projectedPosition, rotation)) {
 399:     // offset is specified as ENU
 400:     // when in globe projection, rotate offset so that the ground alighs with the surface of the globe
 401:     offset = rotation * offset;
 402:   }
 403:   commonPosition = vec4(projectedPosition + offset, 1.0);
 404:   return project_common_position_to_clipspace(commonPosition);
 405: }
 406: 
 407: vec4 project_position_to_clipspace(
 408:   vec3 position, vec3 position64Low, vec3 offset
 409: ) {
 410:   vec4 commonPosition;
 411:   return project_position_to_clipspace(position, position64Low, offset, commonPosition);
 412: }
 413: 
 414: // ----- MODULE picking ---------------
 415: 
 416: #define MODULE_PICKING
 417: uniform pickingUniforms {
 418:   float isActive;
 419:   float isAttribute;
 420:   float isHighlightActive;
 421:   float useFloatColors;
 422:   vec3 highlightedObjectColor;
 423:   vec4 highlightColor;
 424: } picking;
 425: 
 426: out vec4 picking_vRGBcolor_Avalid;
 427: 
 428: // Normalize unsigned byte color to 0-1 range
 429: vec3 picking_normalizeColor(vec3 color) {
 430:   return picking.useFloatColors > 0.5 ? color : color / 255.0;
 431: }
 432: 
 433: // Normalize unsigned byte color to 0-1 range
 434: vec4 picking_normalizeColor(vec4 color) {
 435:   return picking.useFloatColors > 0.5 ? color : color / 255.0;
 436: }
 437: 
 438: bool picking_isColorZero(vec3 color) {
 439:   return dot(color, vec3(1.0)) < 0.00001;
 440: }
 441: 
 442: bool picking_isColorValid(vec3 color) {
 443:   return dot(color, vec3(1.0)) > 0.00001;
 444: }
 445: 
 446: // Check if this vertex is highlighted 
 447: bool isVertexHighlighted(vec3 vertexColor) {
 448:   vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
 449:   return
 450:     bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));
 451: }
 452: 
 453: // Set the current picking color
 454: void picking_setPickingColor(vec3 pickingColor) {
 455:   pickingColor = picking_normalizeColor(pickingColor);
 456: 
 457:   if (bool(picking.isActive)) {
 458:     // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable
 459:     picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));
 460: 
 461:     if (!bool(picking.isAttribute)) {
 462:       // Stores the picking color so that the fragment shader can render it during picking
 463:       picking_vRGBcolor_Avalid.rgb = pickingColor;
 464:     }
 465:   } else {
 466:     // Do the comparison with selected item color in vertex shader as it should mean fewer compares
 467:     picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));
 468:   }
 469: }
 470: 
 471: void picking_setPickingAttribute(float value) {
 472:   if (bool(picking.isAttribute)) {
 473:     picking_vRGBcolor_Avalid.r = value;
 474:   }
 475: }
 476: 
 477: void picking_setPickingAttribute(vec2 value) {
 478:   if (bool(picking.isAttribute)) {
 479:     picking_vRGBcolor_Avalid.rg = value;
 480:   }
 481: }
 482: 
 483: void picking_setPickingAttribute(vec3 value) {
 484:   if (bool(picking.isAttribute)) {
 485:     picking_vRGBcolor_Avalid.rgb = value;
 486:   }
 487: }
 488: 
 489: // ----- MODULE scatterplot ---------------
 490: 
 491: #define MODULE_SCATTERPLOT
 492: uniform scatterplotUniforms {
 493:   float radiusScale;
 494:   float radiusMinPixels;
 495:   float radiusMaxPixels;
 496:   float lineWidthScale;
 497:   float lineWidthMinPixels;
 498:   float lineWidthMaxPixels;
 499:   float stroked;
 500:   float filled;
 501:   bool antialiasing;
 502:   bool billboard;
 503:   highp int radiusUnits;
 504:   highp int lineWidthUnits;
 505: } scatterplot;
 506: 
 507: // ----- MODULE layer ---------------
 508: 
 509: #define MODULE_LAYER
 510: uniform layerUniforms {
 511:   uniform float opacity;
 512: } layer;
 513: 
 514: // ----- MAIN SHADER SOURCE -------------------------
 515: 
 516: 
 517: #define SHADER_NAME scatterplot-layer-vertex-shader
 518: in vec3 positions;
 519: in vec3 instancePositions;
 520: in vec3 instancePositions64Low;
 521: in float instanceRadius;
 522: in float instanceLineWidths;
 523: in vec4 instanceFillColors;
 524: in vec4 instanceLineColors;
 525: in vec3 instancePickingColors;
 526: out vec4 vFillColor;
 527: out vec4 vLineColor;
 528: out vec2 unitPosition;
 529: out float innerUnitRadius;
 530: out float outerRadiusPixels;
 531: void main(void) {
 532: geometry.worldPosition = instancePositions;
 533: outerRadiusPixels = clamp(
 534: project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),
 535: scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
 536: );
 537: float lineWidthPixels = clamp(
 538: project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),
 539: scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
 540: );
 541: outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
 542: float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
 543: unitPosition = edgePadding * positions.xy;
 544: geometry.uv = unitPosition;
 545: geometry.pickingColor = instancePickingColors;
 546: innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;
 547: if (scatterplot.billboard) {
 548: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
 549: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
 ERROR: 'DECKGL_FILTER_GL_POSITION' : no matching overloaded function found
 550: vec3 offset = edgePadding * positions * outerRadiusPixels;
 551: DECKGL_FILTER_SIZE(offset, geometry);
 ERROR: 'DECKGL_FILTER_SIZE' : no matching overloaded function found
 552: gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
 553: } else {
 554: vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
 555: DECKGL_FILTER_SIZE(offset, geometry);
 ERROR: 'DECKGL_FILTER_SIZE' : no matching overloaded function found
 556: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
 557: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
 ERROR: 'DECKGL_FILTER_GL_POSITION' : no matching overloaded function found
 558: }
 559: vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
 560: DECKGL_FILTER_COLOR(vFillColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 561: vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
 562: DECKGL_FILTER_COLOR(vLineColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 563: }


Shader Compilation Error in fragment scatterplot-layer-fragment-shader


   1: #version 300 es
   2: 
   3: // ----- PROLOGUE -------------------------
   4: 
   5: #define SHADER_TYPE_FRAGMENT
   6: 
   7: #define APPLE_GPU
   8: // Apple optimizes away the calculation necessary for emulated fp64
   9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
  10: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
  11: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
  12: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
  13: 
  14: precision highp float;
  15: 
  16: 
  17: // ----- APPLICATION DEFINES -------------------------
  18: 
  19: 
  20: 
  21: // ----- MODULE fp32 ---------------
  22: 
  23: #define MODULE_FP32
  24: 
  25: // ----- MODULE geometry ---------------
  26: 
  27: #define MODULE_GEOMETRY
  28: #define SMOOTH_EDGE_RADIUS 0.5
  29: 
  30: struct FragmentGeometry {
  31:   vec2 uv;
  32: } geometry;
  33: 
  34: float smoothedge(float edge, float x) {
  35:   return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
  36: }
  37: 
  38: // ----- MODULE project ---------------
  39: 
  40: #define MODULE_PROJECT
  41: 
  42: // ----- MODULE project32 ---------------
  43: 
  44: #define MODULE_PROJECT32
  45: 
  46: // ----- MODULE picking ---------------
  47: 
  48: #define MODULE_PICKING
  49: uniform pickingUniforms {
  50:   float isActive;
  51:   float isAttribute;
  52:   float isHighlightActive;
  53:   float useFloatColors;
  54:   vec3 highlightedObjectColor;
  55:   vec4 highlightColor;
  56: } picking;
  57: 
  58: in vec4 picking_vRGBcolor_Avalid;
  59: 
  60: /*
  61:  * Returns highlight color if this item is selected.
  62:  */
  63: vec4 picking_filterHighlightColor(vec4 color) {
  64:   // If we are still picking, we don't highlight
  65:   if (picking.isActive > 0.5) {
  66:     return color;
  67:   }
  68: 
  69:   bool selected = bool(picking_vRGBcolor_Avalid.a);
  70: 
  71:   if (selected) {
  72:     // Blend in highlight color based on its alpha value
  73:     float highLightAlpha = picking.highlightColor.a;
  74:     float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
  75:     float highLightRatio = highLightAlpha / blendedAlpha;
  76: 
  77:     vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);
  78:     return vec4(blendedRGB, blendedAlpha);
  79:   } else {
  80:     return color;
  81:   }
  82: }
  83: 
  84: /*
  85:  * Returns picking color if picking enabled else unmodified argument.
  86:  */
  87: vec4 picking_filterPickingColor(vec4 color) {
  88:   if (bool(picking.isActive)) {
  89:     if (picking_vRGBcolor_Avalid.a == 0.0) {
  90:       discard;
  91:     }
  92:     return picking_vRGBcolor_Avalid;
  93:   }
  94:   return color;
  95: }
  96: 
  97: /*
  98:  * Returns picking color if picking is enabled if not
  99:  * highlight color if this item is selected, otherwise unmodified argument.
 100:  */
 101: vec4 picking_filterColor(vec4 color) {
 102:   vec4 highlightColor = picking_filterHighlightColor(color);
 103:   return picking_filterPickingColor(highlightColor);
 104: }
 105: 
 106: // ----- MODULE scatterplot ---------------
 107: 
 108: #define MODULE_SCATTERPLOT
 109: uniform scatterplotUniforms {
 110:   float radiusScale;
 111:   float radiusMinPixels;
 112:   float radiusMaxPixels;
 113:   float lineWidthScale;
 114:   float lineWidthMinPixels;
 115:   float lineWidthMaxPixels;
 116:   float stroked;
 117:   float filled;
 118:   bool antialiasing;
 119:   bool billboard;
 120:   highp int radiusUnits;
 121:   highp int lineWidthUnits;
 122: } scatterplot;
 123: 
 124: // ----- MODULE layer ---------------
 125: 
 126: #define MODULE_LAYER
 127: uniform layerUniforms {
 128:   uniform float opacity;
 129: } layer;
 130: 
 131: // ----- MAIN SHADER SOURCE -------------------------
 132: 
 133: 
 134: #define SHADER_NAME scatterplot-layer-fragment-shader
 135: precision highp float;
 136: in vec4 vFillColor;
 137: in vec4 vLineColor;
 138: in vec2 unitPosition;
 139: in float innerUnitRadius;
 140: in float outerRadiusPixels;
 141: out vec4 fragColor;
 142: void main(void) {
 143: geometry.uv = unitPosition;
 144: float distToCenter = length(unitPosition) * outerRadiusPixels;
 145: float inCircle = scatterplot.antialiasing ?
 146: smoothedge(distToCenter, outerRadiusPixels) :
 147: step(distToCenter, outerRadiusPixels);
 148: if (inCircle == 0.0) {
 149: discard;
 150: }
 151: if (scatterplot.stroked > 0.5) {
 152: float isLine = scatterplot.antialiasing ?
 153: smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
 154: step(innerUnitRadius * outerRadiusPixels, distToCenter);
 155: if (scatterplot.filled > 0.5) {
 156: fragColor = mix(vFillColor, vLineColor, isLine);
 157: } else {
 158: if (isLine == 0.0) {
 159: discard;
 160: }
 161: fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
 162: }
 163: } else if (scatterplot.filled < 0.5) {
 164: discard;
 165: } else {
 166: fragColor = vFillColor;
 167: }
 168: fragColor.a *= inCircle;
 169: DECKGL_FILTER_COLOR(fragColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 170: }


Shader Compilation Error in vertex scatterplot-layer-vertex-shader


   1: #version 300 es
   2: 
   3: // ----- PROLOGUE -------------------------
   4: 
   5: #define SHADER_TYPE_VERTEX
   6: 
   7: #define APPLE_GPU
   8: // Apple optimizes away the calculation necessary for emulated fp64
   9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
  10: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
  11: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
  12: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
  13: 
  14: 
  15: 
  16: // ----- APPLICATION DEFINES -------------------------
  17: 
  18: 
  19: 
  20: // ----- MODULE fp32 ---------------
  21: 
  22: #define MODULE_FP32
  23: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
  24: 
  25: // All these functions are for substituting tan() function from Intel GPU only
  26: const float TWO_PI = 6.2831854820251465;
  27: const float PI_2 = 1.5707963705062866;
  28: const float PI_16 = 0.1963495463132858;
  29: 
  30: const float SIN_TABLE_0 = 0.19509032368659973;
  31: const float SIN_TABLE_1 = 0.3826834261417389;
  32: const float SIN_TABLE_2 = 0.5555702447891235;
  33: const float SIN_TABLE_3 = 0.7071067690849304;
  34: 
  35: const float COS_TABLE_0 = 0.9807852506637573;
  36: const float COS_TABLE_1 = 0.9238795042037964;
  37: const float COS_TABLE_2 = 0.8314695954322815;
  38: const float COS_TABLE_3 = 0.7071067690849304;
  39: 
  40: const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!
  41: const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!
  42: const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
  43: const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!
  44: 
  45: float sin_taylor_fp32(float a) {
  46:   float r, s, t, x;
  47: 
  48:   if (a == 0.0) {
  49:     return 0.0;
  50:   }
  51: 
  52:   x = -a * a;
  53:   s = a;
  54:   r = a;
  55: 
  56:   r = r * x;
  57:   t = r * INVERSE_FACTORIAL_3;
  58:   s = s + t;
  59: 
  60:   r = r * x;
  61:   t = r * INVERSE_FACTORIAL_5;
  62:   s = s + t;
  63: 
  64:   r = r * x;
  65:   t = r * INVERSE_FACTORIAL_7;
  66:   s = s + t;
  67: 
  68:   r = r * x;
  69:   t = r * INVERSE_FACTORIAL_9;
  70:   s = s + t;
  71: 
  72:   return s;
  73: }
  74: 
  75: void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {
  76:   if (a == 0.0) {
  77:     sin_t = 0.0;
  78:     cos_t = 1.0;
  79:   }
  80:   sin_t = sin_taylor_fp32(a);
  81:   cos_t = sqrt(1.0 - sin_t * sin_t);
  82: }
  83: 
  84: float tan_taylor_fp32(float a) {
  85:     float sin_a;
  86:     float cos_a;
  87: 
  88:     if (a == 0.0) {
  89:         return 0.0;
  90:     }
  91: 
  92:     // 2pi range reduction
  93:     float z = floor(a / TWO_PI);
  94:     float r = a - TWO_PI * z;
  95: 
  96:     float t;
  97:     float q = floor(r / PI_2 + 0.5);
  98:     int j = int(q);
  99: 
 100:     if (j < -2 || j > 2) {
 101:         return 1.0 / 0.0;
 WARNING: '/' : Divide by zero during constant folding
 102:     }
 103: 
 104:     t = r - PI_2 * q;
 105: 
 106:     q = floor(t / PI_16 + 0.5);
 107:     int k = int(q);
 108:     int abs_k = int(abs(float(k)));
 109: 
 110:     if (abs_k > 4) {
 111:         return 1.0 / 0.0;
 WARNING: '/' : Divide by zero during constant folding
 112:     } else {
 113:         t = t - PI_16 * q;
 114:     }
 115: 
 116:     float u = 0.0;
 117:     float v = 0.0;
 118: 
 119:     float sin_t, cos_t;
 120:     float s, c;
 121:     sincos_taylor_fp32(t, sin_t, cos_t);
 122: 
 123:     if (k == 0) {
 124:         s = sin_t;
 125:         c = cos_t;
 126:     } else {
 127:         if (abs(float(abs_k) - 1.0) < 0.5) {
 128:             u = COS_TABLE_0;
 129:             v = SIN_TABLE_0;
 130:         } else if (abs(float(abs_k) - 2.0) < 0.5) {
 131:             u = COS_TABLE_1;
 132:             v = SIN_TABLE_1;
 133:         } else if (abs(float(abs_k) - 3.0) < 0.5) {
 134:             u = COS_TABLE_2;
 135:             v = SIN_TABLE_2;
 136:         } else if (abs(float(abs_k) - 4.0) < 0.5) {
 137:             u = COS_TABLE_3;
 138:             v = SIN_TABLE_3;
 139:         }
 140:         if (k > 0) {
 141:             s = u * sin_t + v * cos_t;
 142:             c = u * cos_t - v * sin_t;
 143:         } else {
 144:             s = u * sin_t - v * cos_t;
 145:             c = u * cos_t + v * sin_t;
 146:         }
 147:     }
 148: 
 149:     if (j == 0) {
 150:         sin_a = s;
 151:         cos_a = c;
 152:     } else if (j == 1) {
 153:         sin_a = c;
 154:         cos_a = -s;
 155:     } else if (j == -1) {
 156:         sin_a = -c;
 157:         cos_a = s;
 158:     } else {
 159:         sin_a = -s;
 160:         cos_a = -c;
 161:     }
 162:     return sin_a / cos_a;
 163: }
 164: #endif
 165: 
 166: float tan_fp32(float a) {
 167: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
 168:   return tan_taylor_fp32(a);
 169: #else
 170:   return tan(a);
 171: #endif
 172: }
 173: 
 174: // ----- MODULE geometry ---------------
 175: 
 176: #define MODULE_GEOMETRY
 177: #define SMOOTH_EDGE_RADIUS 0.5
 178: 
 179: struct VertexGeometry {
 180:   vec4 position;
 181:   vec3 worldPosition;
 182:   vec3 worldPositionAlt;
 183:   vec3 normal;
 184:   vec2 uv;
 185:   vec3 pickingColor;
 186: } geometry = VertexGeometry(
 187:   vec4(0.0, 0.0, 1.0, 0.0),
 188:   vec3(0.0),
 189:   vec3(0.0),
 190:   vec3(0.0),
 191:   vec2(0.0),
 192:   vec3(0.0)
 193: );
 194: 
 195: // ----- MODULE project ---------------
 196: 
 197: #define MODULE_PROJECT
 198: const int COORDINATE_SYSTEM_DEFAULT = -1;const int COORDINATE_SYSTEM_LNGLAT = 1;const int COORDINATE_SYSTEM_METER_OFFSETS = 2;const int COORDINATE_SYSTEM_LNGLAT_OFFSETS = 3;const int COORDINATE_SYSTEM_CARTESIAN = 0;
 199: const int PROJECTION_MODE_WEB_MERCATOR = 1;const int PROJECTION_MODE_GLOBE = 2;const int PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET = 4;const int PROJECTION_MODE_IDENTITY = 0;
 200: const int UNIT_COMMON = 0;const int UNIT_METERS = 1;const int UNIT_PIXELS = 2;
 201: uniform projectUniforms {
 202: bool wrapLongitude;
 203: int coordinateSystem;
 204: vec3 commonUnitsPerMeter;
 205: int projectionMode;
 206: float scale;
 207: vec3 commonUnitsPerWorldUnit;
 208: vec3 commonUnitsPerWorldUnit2;
 209: vec4 center;
 210: mat4 modelMatrix;
 211: mat4 viewProjectionMatrix;
 212: vec2 viewportSize;
 213: float devicePixelRatio;
 214: float focalDistance;
 215: vec3 cameraPosition;
 216: vec3 coordinateOrigin;
 217: vec3 commonOrigin;
 218: bool pseudoMeters;
 219: } project;
 220: const float TILE_SIZE = 512.0;
 221: const float PI = 3.1415926536;
 222: const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
 223: const vec3 ZERO_64_LOW = vec3(0.0);
 224: const float EARTH_RADIUS = 6370972.0;
 225: const float GLOBE_RADIUS = 256.0;
 226: float project_size_at_latitude(float lat) {
 227: float y = clamp(lat, -89.9, 89.9);
 228: return 1.0 / cos(radians(y));
 229: }
 230: float project_size() {
 231: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
 232: project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
 233: project.pseudoMeters == false) {
 234: if (geometry.position.w == 0.0) {
 235: return project_size_at_latitude(geometry.worldPosition.y);
 236: }
 237: float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
 238: float y2 = y * y;
 239: float y4 = y2 * y2;
 240: float y6 = y4 * y2;
 241: return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
 242: }
 243: return 1.0;
 244: }
 245: float project_size_at_latitude(float meters, float lat) {
 246: return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
 247: }
 248: float project_size(float meters) {
 249: return meters * project.commonUnitsPerMeter.z * project_size();
 250: }
 251: vec2 project_size(vec2 meters) {
 252: return meters * project.commonUnitsPerMeter.xy * project_size();
 253: }
 254: vec3 project_size(vec3 meters) {
 255: return meters * project.commonUnitsPerMeter * project_size();
 256: }
 257: vec4 project_size(vec4 meters) {
 258: return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
 259: }
 260: mat3 project_get_orientation_matrix(vec3 up) {
 261: vec3 uz = normalize(up);
 262: vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
 263: vec3 uy = cross(uz, ux);
 264: return mat3(ux, uy, uz);
 265: }
 266: bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
 267: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
 268: transform = project_get_orientation_matrix(commonPosition);
 269: return true;
 270: }
 271: return false;
 272: }
 273: vec3 project_normal(vec3 vector) {
 274: vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
 275: vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
 276: mat3 rotation;
 277: if (project_needs_rotation(geometry.position.xyz, rotation)) {
 278: n = rotation * n;
 279: }
 280: return n;
 281: }
 282: vec4 project_offset_(vec4 offset) {
 283: float dy = offset.y;
 284: vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
 285: return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
 286: }
 287: vec2 project_mercator_(vec2 lnglat) {
 288: float x = lnglat.x;
 289: if (project.wrapLongitude) {
 290: x = mod(x + 180., 360.0) - 180.;
 291: }
 292: float y = clamp(lnglat.y, -89.9, 89.9);
 293: return vec2(
 294: radians(x) + PI,
 295: PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
 296: ) * WORLD_SCALE;
 297: }
 298: vec3 project_globe_(vec3 lnglatz) {
 299: float lambda = radians(lnglatz.x);
 300: float phi = radians(lnglatz.y);
 301: float cosPhi = cos(phi);
 302: float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
 303: return vec3(
 304: sin(lambda) * cosPhi,
 305: -cos(lambda) * cosPhi,
 306: sin(phi)
 307: ) * D;
 308: }
 309: vec4 project_position(vec4 position, vec3 position64Low) {
 310: vec4 position_world = project.modelMatrix * position;
 311: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
 312: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 313: return vec4(
 314: project_mercator_(position_world.xy),
 315: project_size_at_latitude(position_world.z, position_world.y),
 316: position_world.w
 317: );
 318: }
 319: if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
 320: position_world.xyz += project.coordinateOrigin;
 321: }
 322: }
 323: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
 324: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 325: return vec4(
 326: project_globe_(position_world.xyz),
 327: position_world.w
 328: );
 329: }
 330: }
 331: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
 332: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
 333: if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
 334: return vec4(
 335: project_mercator_(position_world.xy) - project.commonOrigin.xy,
 336: project_size(position_world.z),
 337: position_world.w
 338: );
 339: }
 340: }
 341: }
 342: if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
 343: (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
 344: (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
 345: project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
 346: position_world.xyz -= project.coordinateOrigin;
 347: }
 348: return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
 349: }
 350: vec4 project_position(vec4 position) {
 351: return project_position(position, ZERO_64_LOW);
 352: }
 353: vec3 project_position(vec3 position, vec3 position64Low) {
 354: vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
 355: return projected_position.xyz;
 356: }
 357: vec3 project_position(vec3 position) {
 358: vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
 359: return projected_position.xyz;
 360: }
 361: vec2 project_position(vec2 position) {
 362: vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
 363: return projected_position.xy;
 364: }
 365: vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
 366: return viewProjectionMatrix * position + center;
 367: }
 368: vec4 project_common_position_to_clipspace(vec4 position) {
 369: return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
 370: }
 371: vec2 project_pixel_size_to_clipspace(vec2 pixels) {
 372: vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
 373: return offset * project.focalDistance;
 374: }
 375: float project_size_to_pixel(float meters) {
 376: return project_size(meters) * project.scale;
 377: }
 378: float project_size_to_pixel(float size, int unit) {
 379: if (unit == UNIT_METERS) return project_size_to_pixel(size);
 380: if (unit == UNIT_COMMON) return size * project.scale;
 381: return size;
 382: }
 383: float project_pixel_size(float pixels) {
 384: return pixels / project.scale;
 385: }
 386: vec2 project_pixel_size(vec2 pixels) {
 387: return pixels / project.scale;
 388: }
 389: 
 390: // ----- MODULE project32 ---------------
 391: 
 392: #define MODULE_PROJECT32
 393: vec4 project_position_to_clipspace(
 394:   vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
 395: ) {
 396:   vec3 projectedPosition = project_position(position, position64Low);
 397:   mat3 rotation;
 398:   if (project_needs_rotation(projectedPosition, rotation)) {
 399:     // offset is specified as ENU
 400:     // when in globe projection, rotate offset so that the ground alighs with the surface of the globe
 401:     offset = rotation * offset;
 402:   }
 403:   commonPosition = vec4(projectedPosition + offset, 1.0);
 404:   return project_common_position_to_clipspace(commonPosition);
 405: }
 406: 
 407: vec4 project_position_to_clipspace(
 408:   vec3 position, vec3 position64Low, vec3 offset
 409: ) {
 410:   vec4 commonPosition;
 411:   return project_position_to_clipspace(position, position64Low, offset, commonPosition);
 412: }
 413: 
 414: // ----- MODULE picking ---------------
 415: 
 416: #define MODULE_PICKING
 417: uniform pickingUniforms {
 418:   float isActive;
 419:   float isAttribute;
 420:   float isHighlightActive;
 421:   float useFloatColors;
 422:   vec3 highlightedObjectColor;
 423:   vec4 highlightColor;
 424: } picking;
 425: 
 426: out vec4 picking_vRGBcolor_Avalid;
 427: 
 428: // Normalize unsigned byte color to 0-1 range
 429: vec3 picking_normalizeColor(vec3 color) {
 430:   return picking.useFloatColors > 0.5 ? color : color / 255.0;
 431: }
 432: 
 433: // Normalize unsigned byte color to 0-1 range
 434: vec4 picking_normalizeColor(vec4 color) {
 435:   return picking.useFloatColors > 0.5 ? color : color / 255.0;
 436: }
 437: 
 438: bool picking_isColorZero(vec3 color) {
 439:   return dot(color, vec3(1.0)) < 0.00001;
 440: }
 441: 
 442: bool picking_isColorValid(vec3 color) {
 443:   return dot(color, vec3(1.0)) > 0.00001;
 444: }
 445: 
 446: // Check if this vertex is highlighted 
 447: bool isVertexHighlighted(vec3 vertexColor) {
 448:   vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
 449:   return
 450:     bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));
 451: }
 452: 
 453: // Set the current picking color
 454: void picking_setPickingColor(vec3 pickingColor) {
 455:   pickingColor = picking_normalizeColor(pickingColor);
 456: 
 457:   if (bool(picking.isActive)) {
 458:     // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable
 459:     picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));
 460: 
 461:     if (!bool(picking.isAttribute)) {
 462:       // Stores the picking color so that the fragment shader can render it during picking
 463:       picking_vRGBcolor_Avalid.rgb = pickingColor;
 464:     }
 465:   } else {
 466:     // Do the comparison with selected item color in vertex shader as it should mean fewer compares
 467:     picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));
 468:   }
 469: }
 470: 
 471: void picking_setPickingAttribute(float value) {
 472:   if (bool(picking.isAttribute)) {
 473:     picking_vRGBcolor_Avalid.r = value;
 474:   }
 475: }
 476: 
 477: void picking_setPickingAttribute(vec2 value) {
 478:   if (bool(picking.isAttribute)) {
 479:     picking_vRGBcolor_Avalid.rg = value;
 480:   }
 481: }
 482: 
 483: void picking_setPickingAttribute(vec3 value) {
 484:   if (bool(picking.isAttribute)) {
 485:     picking_vRGBcolor_Avalid.rgb = value;
 486:   }
 487: }
 488: 
 489: // ----- MODULE scatterplot ---------------
 490: 
 491: #define MODULE_SCATTERPLOT
 492: uniform scatterplotUniforms {
 493:   float radiusScale;
 494:   float radiusMinPixels;
 495:   float radiusMaxPixels;
 496:   float lineWidthScale;
 497:   float lineWidthMinPixels;
 498:   float lineWidthMaxPixels;
 499:   float stroked;
 500:   float filled;
 501:   bool antialiasing;
 502:   bool billboard;
 503:   highp int radiusUnits;
 504:   highp int lineWidthUnits;
 505: } scatterplot;
 506: 
 507: // ----- MODULE layer ---------------
 508: 
 509: #define MODULE_LAYER
 510: uniform layerUniforms {
 511:   uniform float opacity;
 512: } layer;
 513: 
 514: // ----- MAIN SHADER SOURCE -------------------------
 515: 
 516: 
 517: #define SHADER_NAME scatterplot-layer-vertex-shader
 518: in vec3 positions;
 519: in vec3 instancePositions;
 520: in vec3 instancePositions64Low;
 521: in float instanceRadius;
 522: in float instanceLineWidths;
 523: in vec4 instanceFillColors;
 524: in vec4 instanceLineColors;
 525: in vec3 instancePickingColors;
 526: out vec4 vFillColor;
 527: out vec4 vLineColor;
 528: out vec2 unitPosition;
 529: out float innerUnitRadius;
 530: out float outerRadiusPixels;
 531: void main(void) {
 532: geometry.worldPosition = instancePositions;
 533: outerRadiusPixels = clamp(
 534: project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),
 535: scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
 536: );
 537: float lineWidthPixels = clamp(
 538: project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),
 539: scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
 540: );
 541: outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
 542: float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
 543: unitPosition = edgePadding * positions.xy;
 544: geometry.uv = unitPosition;
 545: geometry.pickingColor = instancePickingColors;
 546: innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;
 547: if (scatterplot.billboard) {
 548: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
 549: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
 ERROR: 'DECKGL_FILTER_GL_POSITION' : no matching overloaded function found
 550: vec3 offset = edgePadding * positions * outerRadiusPixels;
 551: DECKGL_FILTER_SIZE(offset, geometry);
 ERROR: 'DECKGL_FILTER_SIZE' : no matching overloaded function found
 552: gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
 553: } else {
 554: vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
 555: DECKGL_FILTER_SIZE(offset, geometry);
 ERROR: 'DECKGL_FILTER_SIZE' : no matching overloaded function found
 556: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
 557: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
 ERROR: 'DECKGL_FILTER_GL_POSITION' : no matching overloaded function found
 558: }
 559: vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
 560: DECKGL_FILTER_COLOR(vFillColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 561: vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
 562: DECKGL_FILTER_COLOR(vLineColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 563: }


Shader Compilation Error in fragment scatterplot-layer-fragment-shader


   1: #version 300 es
   2: 
   3: // ----- PROLOGUE -------------------------
   4: 
   5: #define SHADER_TYPE_FRAGMENT
   6: 
   7: #define APPLE_GPU
   8: // Apple optimizes away the calculation necessary for emulated fp64
   9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
  10: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
  11: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
  12: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
  13: 
  14: precision highp float;
  15: 
  16: 
  17: // ----- APPLICATION DEFINES -------------------------
  18: 
  19: 
  20: 
  21: // ----- MODULE fp32 ---------------
  22: 
  23: #define MODULE_FP32
  24: 
  25: // ----- MODULE geometry ---------------
  26: 
  27: #define MODULE_GEOMETRY
  28: #define SMOOTH_EDGE_RADIUS 0.5
  29: 
  30: struct FragmentGeometry {
  31:   vec2 uv;
  32: } geometry;
  33: 
  34: float smoothedge(float edge, float x) {
  35:   return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
  36: }
  37: 
  38: // ----- MODULE project ---------------
  39: 
  40: #define MODULE_PROJECT
  41: 
  42: // ----- MODULE project32 ---------------
  43: 
  44: #define MODULE_PROJECT32
  45: 
  46: // ----- MODULE picking ---------------
  47: 
  48: #define MODULE_PICKING
  49: uniform pickingUniforms {
  50:   float isActive;
  51:   float isAttribute;
  52:   float isHighlightActive;
  53:   float useFloatColors;
  54:   vec3 highlightedObjectColor;
  55:   vec4 highlightColor;
  56: } picking;
  57: 
  58: in vec4 picking_vRGBcolor_Avalid;
  59: 
  60: /*
  61:  * Returns highlight color if this item is selected.
  62:  */
  63: vec4 picking_filterHighlightColor(vec4 color) {
  64:   // If we are still picking, we don't highlight
  65:   if (picking.isActive > 0.5) {
  66:     return color;
  67:   }
  68: 
  69:   bool selected = bool(picking_vRGBcolor_Avalid.a);
  70: 
  71:   if (selected) {
  72:     // Blend in highlight color based on its alpha value
  73:     float highLightAlpha = picking.highlightColor.a;
  74:     float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
  75:     float highLightRatio = highLightAlpha / blendedAlpha;
  76: 
  77:     vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);
  78:     return vec4(blendedRGB, blendedAlpha);
  79:   } else {
  80:     return color;
  81:   }
  82: }
  83: 
  84: /*
  85:  * Returns picking color if picking enabled else unmodified argument.
  86:  */
  87: vec4 picking_filterPickingColor(vec4 color) {
  88:   if (bool(picking.isActive)) {
  89:     if (picking_vRGBcolor_Avalid.a == 0.0) {
  90:       discard;
  91:     }
  92:     return picking_vRGBcolor_Avalid;
  93:   }
  94:   return color;
  95: }
  96: 
  97: /*
  98:  * Returns picking color if picking is enabled if not
  99:  * highlight color if this item is selected, otherwise unmodified argument.
 100:  */
 101: vec4 picking_filterColor(vec4 color) {
 102:   vec4 highlightColor = picking_filterHighlightColor(color);
 103:   return picking_filterPickingColor(highlightColor);
 104: }
 105: 
 106: // ----- MODULE scatterplot ---------------
 107: 
 108: #define MODULE_SCATTERPLOT
 109: uniform scatterplotUniforms {
 110:   float radiusScale;
 111:   float radiusMinPixels;
 112:   float radiusMaxPixels;
 113:   float lineWidthScale;
 114:   float lineWidthMinPixels;
 115:   float lineWidthMaxPixels;
 116:   float stroked;
 117:   float filled;
 118:   bool antialiasing;
 119:   bool billboard;
 120:   highp int radiusUnits;
 121:   highp int lineWidthUnits;
 122: } scatterplot;
 123: 
 124: // ----- MODULE layer ---------------
 125: 
 126: #define MODULE_LAYER
 127: uniform layerUniforms {
 128:   uniform float opacity;
 129: } layer;
 130: 
 131: // ----- MAIN SHADER SOURCE -------------------------
 132: 
 133: 
 134: #define SHADER_NAME scatterplot-layer-fragment-shader
 135: precision highp float;
 136: in vec4 vFillColor;
 137: in vec4 vLineColor;
 138: in vec2 unitPosition;
 139: in float innerUnitRadius;
 140: in float outerRadiusPixels;
 141: out vec4 fragColor;
 142: void main(void) {
 143: geometry.uv = unitPosition;
 144: float distToCenter = length(unitPosition) * outerRadiusPixels;
 145: float inCircle = scatterplot.antialiasing ?
 146: smoothedge(distToCenter, outerRadiusPixels) :
 147: step(distToCenter, outerRadiusPixels);
 148: if (inCircle == 0.0) {
 149: discard;
 150: }
 151: if (scatterplot.stroked > 0.5) {
 152: float isLine = scatterplot.antialiasing ?
 153: smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
 154: step(innerUnitRadius * outerRadiusPixels, distToCenter);
 155: if (scatterplot.filled > 0.5) {
 156: fragColor = mix(vFillColor, vLineColor, isLine);
 157: } else {
 158: if (isLine == 0.0) {
 159: discard;
 160: }
 161: fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
 162: }
 163: } else if (scatterplot.filled < 0.5) {
 164: discard;
 165: } else {
 166: fragColor = vFillColor;
 167: }
 168: fragColor.a *= inCircle;
 169: DECKGL_FILTER_COLOR(fragColor, geometry);
 ERROR: 'DECKGL_FILTER_COLOR' : no matching overloaded function found
 170: }

Maybe this is a luma version error?

@felixpalmer
Copy link

The shader hooks are not being installed for some reason. This has happened in the past with packaging issues, it is strange that your changes would break this. Could you try to update to use the latest version of deck.gl? Either 9.1 of 9.2-beta?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants