Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | //This file is automatically rebuilt by the Cesium build process.
export default "uniform float u_threePointDepthTestDistance;\n\
#ifdef INSTANCED\n\
in vec2 direction;\n\
#endif\n\
in vec4 positionHighAndScale;\n\
in vec4 positionLowAndRotation;\n\
in vec4 compressedAttribute0; // pixel offset, translate, horizontal origin, vertical origin, show, direction, texture coordinates (texture offset)\n\
in vec4 compressedAttribute1; // aligned axis, translucency by distance, image width\n\
in vec4 compressedAttribute2; // label horizontal origin, image height, color, pick color, size in meters, valid aligned axis, 13 bits free\n\
in vec4 eyeOffset; // eye offset in meters, 4 bytes free (texture range)\n\
in vec4 scaleByDistance; // near, nearScale, far, farScale\n\
in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale\n\
in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistanceSq, dimensions\n\
in vec2 sdf; // sdf outline color (rgb) and width (w)\n\
in float splitDirection; // splitDirection\n\
#if defined(VS_THREE_POINT_DEPTH_CHECK) || defined(FS_THREE_POINT_DEPTH_CHECK)\n\
in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates\n\
#endif\n\
#ifdef VECTOR_TILE\n\
in float a_batchId;\n\
#endif\n\
\n\
out vec2 v_textureCoordinates;\n\
#ifdef FS_THREE_POINT_DEPTH_CHECK\n\
out vec4 v_textureCoordinateBounds;\n\
out vec4 v_originTextureCoordinateAndTranslate;\n\
out mat2 v_rotationMatrix;\n\
#endif\n\
out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize\n\
\n\
out vec4 v_pickColor;\n\
out vec4 v_color;\n\
out float v_splitDirection;\n\
#ifdef SDF\n\
out vec4 v_outlineColor;\n\
out float v_outlineWidth;\n\
#endif\n\
\n\
const float UPPER_BOUND = 32768.0;\n\
\n\
const float SHIFT_LEFT16 = 65536.0;\n\
const float SHIFT_LEFT12 = 4096.0;\n\
const float SHIFT_LEFT8 = 256.0;\n\
const float SHIFT_LEFT7 = 128.0;\n\
const float SHIFT_LEFT5 = 32.0;\n\
const float SHIFT_LEFT3 = 8.0;\n\
const float SHIFT_LEFT2 = 4.0;\n\
const float SHIFT_LEFT1 = 2.0;\n\
\n\
const float SHIFT_RIGHT12 = 1.0 / 4096.0;\n\
const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\
const float SHIFT_RIGHT7 = 1.0 / 128.0;\n\
const float SHIFT_RIGHT5 = 1.0 / 32.0;\n\
const float SHIFT_RIGHT3 = 1.0 / 8.0;\n\
const float SHIFT_RIGHT2 = 1.0 / 4.0;\n\
const float SHIFT_RIGHT1 = 1.0 / 2.0;\n\
\n\
vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 direction, vec2 origin, vec2 translate, vec2 pixelOffset, vec3 alignedAxis, bool validAlignedAxis, float rotation, bool sizeInMeters, out mat2 rotationMatrix, out float mpp)\n\
{\n\
// Note the halfSize cannot be computed in JavaScript because it is sent via\n\
// compressed vertex attributes that coerce it to an integer.\n\
vec2 halfSize = imageSize * scale * 0.5;\n\
halfSize *= ((direction * 2.0) - 1.0);\n\
\n\
vec2 originTranslate = origin * abs(halfSize);\n\
\n\
#if defined(ROTATION) || defined(ALIGNED_AXIS)\n\
if (validAlignedAxis || rotation != 0.0)\n\
{\n\
float angle = rotation;\n\
if (validAlignedAxis)\n\
{\n\
vec4 projectedAlignedAxis = czm_modelView3D * vec4(alignedAxis, 0.0);\n\
angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /\n\
(projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y));\n\
}\n\
\n\
float cosTheta = cos(angle);\n\
float sinTheta = sin(angle);\n\
rotationMatrix = mat2(cosTheta, sinTheta, -sinTheta, cosTheta);\n\
halfSize = rotationMatrix * halfSize;\n\
}\n\
else\n\
{\n\
rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);\n\
}\n\
#endif\n\
\n\
mpp = czm_metersPerPixel(positionEC);\n\
positionEC.xy += (originTranslate + halfSize) * czm_branchFreeTernary(sizeInMeters, 1.0, mpp);\n\
positionEC.xy += (translate + pixelOffset) * mpp;\n\
\n\
return positionEC;\n\
}\n\
\n\
#ifdef VS_THREE_POINT_DEPTH_CHECK\n\
float getGlobeDepth(vec4 positionEC)\n\
{\n\
vec4 posWC = czm_eyeToWindowCoordinates(positionEC);\n\
\n\
float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, posWC.xy / czm_viewport.zw));\n\
\n\
if (globeDepth == 0.0)\n\
{\n\
return 0.0; // not on the globe\n\
}\n\
\n\
vec4 eyeCoordinate = czm_windowToEyeCoordinates(posWC.xy, globeDepth);\n\
return eyeCoordinate.z / eyeCoordinate.w;\n\
}\n\
#endif\n\
void main()\n\
{\n\
// Modifying this shader may also require modifications to Billboard._computeScreenSpacePosition\n\
\n\
// unpack attributes\n\
vec3 positionHigh = positionHighAndScale.xyz;\n\
vec3 positionLow = positionLowAndRotation.xyz;\n\
float scale = positionHighAndScale.w;\n\
\n\
#if defined(ROTATION) || defined(ALIGNED_AXIS)\n\
float rotation = positionLowAndRotation.w;\n\
#else\n\
float rotation = 0.0;\n\
#endif\n\
\n\
float compressed = compressedAttribute0.x;\n\
\n\
vec2 pixelOffset;\n\
pixelOffset.x = floor(compressed * SHIFT_RIGHT7);\n\
compressed -= pixelOffset.x * SHIFT_LEFT7;\n\
pixelOffset.x -= UPPER_BOUND;\n\
\n\
vec2 origin;\n\
origin.x = floor(compressed * SHIFT_RIGHT5);\n\
compressed -= origin.x * SHIFT_LEFT5;\n\
\n\
origin.y = floor(compressed * SHIFT_RIGHT3);\n\
compressed -= origin.y * SHIFT_LEFT3;\n\
\n\
#ifdef FS_THREE_POINT_DEPTH_CHECK\n\
vec2 depthOrigin = origin.xy;\n\
#endif\n\
origin -= vec2(1.0);\n\
\n\
float show = floor(compressed * SHIFT_RIGHT2);\n\
compressed -= show * SHIFT_LEFT2;\n\
\n\
#ifdef INSTANCED\n\
vec2 textureCoordinatesBottomLeft = czm_decompressTextureCoordinates(compressedAttribute0.w);\n\
vec2 textureCoordinatesRange = czm_decompressTextureCoordinates(eyeOffset.w);\n\
vec2 textureCoordinates = textureCoordinatesBottomLeft + direction * textureCoordinatesRange;\n\
#else\n\
vec2 direction;\n\
direction.x = floor(compressed * SHIFT_RIGHT1);\n\
direction.y = compressed - direction.x * SHIFT_LEFT1;\n\
\n\
vec2 textureCoordinates = czm_decompressTextureCoordinates(compressedAttribute0.w);\n\
#endif\n\
\n\
float temp = compressedAttribute0.y * SHIFT_RIGHT8;\n\
pixelOffset.y = -(floor(temp) - UPPER_BOUND);\n\
\n\
vec2 translate;\n\
translate.y = (temp - floor(temp)) * SHIFT_LEFT16;\n\
\n\
temp = compressedAttribute0.z * SHIFT_RIGHT8;\n\
translate.x = floor(temp) - UPPER_BOUND;\n\
translate.x *= SHIFT_RIGHT2; // undo translateX scaling (helps preserve subpixel precision, see BillboardCollection.js attribute writer for more info)\n\
\n\
translate.y += (temp - floor(temp)) * SHIFT_LEFT8;\n\
translate.y -= UPPER_BOUND;\n\
translate.y *= SHIFT_RIGHT2;\n\
\n\
temp = compressedAttribute1.x * SHIFT_RIGHT8;\n\
float temp2 = floor(compressedAttribute2.w * SHIFT_RIGHT2);\n\
\n\
vec2 imageSize = vec2(floor(temp), temp2);\n\
\n\
#ifdef FS_THREE_POINT_DEPTH_CHECK\n\
float labelHorizontalOrigin = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));\n\
float applyTranslate = 0.0;\n\
if (labelHorizontalOrigin != 0.0) // is a label, so set apply translate to true\n\
{\n\
applyTranslate = 1.0;\n\
labelHorizontalOrigin -= 2.0;\n\
depthOrigin.x = labelHorizontalOrigin + 1.0;\n\
}\n\
\n\
depthOrigin = vec2(1.0) - (depthOrigin * 0.5);\n\
#endif\n\
\n\
#ifdef EYE_DISTANCE_TRANSLUCENCY\n\
vec4 translucencyByDistance;\n\
translucencyByDistance.x = compressedAttribute1.z;\n\
translucencyByDistance.z = compressedAttribute1.w;\n\
\n\
translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
\n\
temp = compressedAttribute1.y * SHIFT_RIGHT8;\n\
translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
#endif\n\
\n\
#if defined(VS_THREE_POINT_DEPTH_CHECK) || defined(FS_THREE_POINT_DEPTH_CHECK)\n\
temp = compressedAttribute3.w;\n\
temp = temp * SHIFT_RIGHT12;\n\
\n\
vec2 dimensions;\n\
dimensions.y = (temp - floor(temp)) * SHIFT_LEFT12;\n\
dimensions.x = floor(temp);\n\
#endif\n\
\n\
#ifdef ALIGNED_AXIS\n\
vec3 alignedAxis = czm_octDecode(floor(compressedAttribute1.y * SHIFT_RIGHT8));\n\
temp = compressedAttribute2.z * SHIFT_RIGHT5;\n\
bool validAlignedAxis = (temp - floor(temp)) * SHIFT_LEFT1 > 0.0;\n\
#else\n\
vec3 alignedAxis = vec3(0.0);\n\
bool validAlignedAxis = false;\n\
#endif\n\
\n\
vec4 pickColor;\n\
vec4 color;\n\
\n\
temp = compressedAttribute2.y;\n\
temp = temp * SHIFT_RIGHT8;\n\
pickColor.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
temp = floor(temp) * SHIFT_RIGHT8;\n\
pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
pickColor.r = floor(temp);\n\
\n\
temp = compressedAttribute2.x;\n\
temp = temp * SHIFT_RIGHT8;\n\
color.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
temp = floor(temp) * SHIFT_RIGHT8;\n\
color.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
color.r = floor(temp);\n\
\n\
temp = compressedAttribute2.z * SHIFT_RIGHT8;\n\
bool sizeInMeters = floor((temp - floor(temp)) * SHIFT_LEFT7) > 0.0;\n\
temp = floor(temp) * SHIFT_RIGHT8;\n\
\n\
pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;\n\
pickColor /= 255.0;\n\
\n\
color.a = floor(temp);\n\
color /= 255.0;\n\
\n\
///////////////////////////////////////////////////////////////////////////\n\
\n\
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
\n\
positionEC = czm_eyeOffset(positionEC, eyeOffset.xyz);\n\
positionEC.xyz *= show;\n\
\n\
///////////////////////////////////////////////////////////////////////////\n\
\n\
#if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(EYE_DISTANCE_PIXEL_OFFSET) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)\n\
float lengthSq;\n\
if (czm_sceneMode == czm_sceneMode2D)\n\
{\n\
// 2D camera distance is a special case\n\
// treat all billboards as flattened to the z=0.0 plane\n\
lengthSq = czm_eyeHeight2D.y;\n\
}\n\
else\n\
{\n\
lengthSq = dot(positionEC.xyz, positionEC.xyz);\n\
}\n\
#endif\n\
\n\
#ifdef EYE_DISTANCE_SCALING\n\
float distanceScale = czm_nearFarScalar(scaleByDistance, lengthSq);\n\
scale *= distanceScale;\n\
translate *= distanceScale;\n\
// push vertex behind near plane for clipping\n\
if (scale == 0.0)\n\
{\n\
positionEC.xyz = vec3(0.0);\n\
}\n\
#endif\n\
\n\
float translucency = 1.0;\n\
#ifdef EYE_DISTANCE_TRANSLUCENCY\n\
translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);\n\
// push vertex behind near plane for clipping\n\
if (translucency == 0.0)\n\
{\n\
positionEC.xyz = vec3(0.0);\n\
}\n\
#endif\n\
\n\
#ifdef EYE_DISTANCE_PIXEL_OFFSET\n\
float pixelOffsetScale = czm_nearFarScalar(pixelOffsetScaleByDistance, lengthSq);\n\
pixelOffset *= pixelOffsetScale;\n\
#endif\n\
\n\
#ifdef DISTANCE_DISPLAY_CONDITION\n\
float nearSq = compressedAttribute3.x;\n\
float farSq = compressedAttribute3.y;\n\
if (lengthSq < nearSq || lengthSq > farSq)\n\
{\n\
positionEC.xyz = vec3(0.0);\n\
}\n\
#endif\n\
\n\
mat2 rotationMatrix;\n\
float mpp;\n\
\n\
float enableDepthCheck = 1.0;\n\
#ifdef DISABLE_DEPTH_DISTANCE\n\
float disableDepthTestDistanceSq = compressedAttribute3.z;\n\
if (disableDepthTestDistanceSq == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)\n\
{\n\
disableDepthTestDistanceSq = czm_minimumDisableDepthTestDistance;\n\
}\n\
\n\
if (lengthSq < disableDepthTestDistanceSq || disableDepthTestDistanceSq < 0.0)\n\
{\n\
enableDepthCheck = 0.0;\n\
}\n\
#endif\n\
\n\
v_compressed.y = enableDepthCheck;\n\
\n\
#ifdef VS_THREE_POINT_DEPTH_CHECK\n\
if (lengthSq < (u_threePointDepthTestDistance * u_threePointDepthTestDistance) && (enableDepthCheck == 1.0)) {\n\
float depthsilon = 10.0;\n\
vec2 depthOrigin;\n\
// Horizontal origin for labels comes from a special attribute. If that value is 0, this is a billboard - use the regular origin. \n\
// Otherwise, transform the label origin to -1, 0, 1 (right, center, left).\n\
depthOrigin.x = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));\n\
depthOrigin.x = czm_branchFreeTernary(depthOrigin.x == 0.0, origin.x, depthOrigin.x - 2.0);\n\
depthOrigin.y = origin.y;\n\
\n\
vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
float globeDepth1 = getGlobeDepth(pEC1);\n\
\n\
if (globeDepth1 != 0.0 && pEC1.z + depthsilon < globeDepth1)\n\
{\n\
vec4 pEC2 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0, 1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
float globeDepth2 = getGlobeDepth(pEC2);\n\
\n\
if (globeDepth2 != 0.0 && pEC2.z + depthsilon < globeDepth2)\n\
{\n\
vec4 pEC3 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
float globeDepth3 = getGlobeDepth(pEC3);\n\
if (globeDepth3 != 0.0 && pEC3.z + depthsilon < globeDepth3)\n\
{\n\
// \"Discard\" this vertex, as three key points fail depth test.\n\
positionEC.xyz = vec3(0.0);\n\
}\n\
}\n\
}\n\
}\n\
#endif\n\
// Write out the eyespace depth before applying the screen space offset, but after potentially \"discarding\" the vertex\n\
// by setting its eyespace position to zero, via the three-point depth test above.\n\
v_compressed.x = positionEC.z;\n\
\n\
positionEC = addScreenSpaceOffset(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
gl_Position = czm_projection * positionEC;\n\
v_textureCoordinates = textureCoordinates;\n\
\n\
#ifdef LOG_DEPTH\n\
czm_vertexLogDepth();\n\
#endif\n\
\n\
#ifdef DISABLE_DEPTH_DISTANCE\n\
\n\
if (disableDepthTestDistanceSq != 0.0)\n\
{\n\
// Don't try to \"multiply both sides\" by w. Greater/less-than comparisons won't work for negative values of w.\n\
float zclip = gl_Position.z / gl_Position.w;\n\
bool clipped = (zclip < -1.0 || zclip > 1.0);\n\
// disableDepthTestDistanceSq can be less than zero if it's explicitly set to -1 in JS (as a sentinel value equivalent to infinity)\n\
if (!clipped && (disableDepthTestDistanceSq < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistanceSq)))\n\
{\n\
// Position z on the near plane.\n\
gl_Position.z = -gl_Position.w;\n\
#ifdef LOG_DEPTH\n\
v_depthFromNearPlusOne = 1.0;\n\
#endif\n\
}\n\
}\n\
#endif\n\
\n\
#ifdef FS_THREE_POINT_DEPTH_CHECK\n\
if (sizeInMeters) {\n\
translate /= mpp;\n\
dimensions /= mpp;\n\
imageSize /= mpp;\n\
}\n\
\n\
#if defined(ROTATION) || defined(ALIGNED_AXIS)\n\
v_rotationMatrix = rotationMatrix;\n\
#else\n\
v_rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);\n\
#endif\n\
float dw = floor(clamp(dimensions.x, 0.0, SHIFT_LEFT12));\n\
float dh = floor(clamp(dimensions.y, 0.0, SHIFT_LEFT12));\n\
\n\
float iw = floor(clamp(imageSize.x, 0.0, SHIFT_LEFT12));\n\
float ih = floor(clamp(imageSize.y, 0.0, SHIFT_LEFT12));\n\
\n\
v_compressed.y += applyTranslate * SHIFT_LEFT1;\n\
v_compressed.z = dw * SHIFT_LEFT12 + dh;\n\
v_compressed.w = iw * SHIFT_LEFT12 + ih;\n\
v_originTextureCoordinateAndTranslate.xy = depthOrigin;\n\
v_originTextureCoordinateAndTranslate.zw = translate;\n\
v_textureCoordinateBounds = textureCoordinateBoundsOrLabelTranslate;\n\
\n\
#endif\n\
\n\
#ifdef SDF\n\
vec4 outlineColor;\n\
float outlineWidth;\n\
\n\
temp = sdf.x;\n\
temp = temp * SHIFT_RIGHT8;\n\
outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
temp = floor(temp) * SHIFT_RIGHT8;\n\
outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
outlineColor.r = floor(temp);\n\
\n\
temp = sdf.y;\n\
temp = temp * SHIFT_RIGHT8;\n\
float temp3 = (temp - floor(temp)) * SHIFT_LEFT8;\n\
temp = floor(temp) * SHIFT_RIGHT8;\n\
outlineWidth = (temp - floor(temp)) * SHIFT_LEFT8;\n\
outlineColor.a = floor(temp);\n\
outlineColor /= 255.0;\n\
\n\
v_outlineWidth = outlineWidth / 255.0;\n\
v_outlineColor = outlineColor;\n\
v_outlineColor.a *= translucency;\n\
#endif\n\
\n\
v_pickColor = pickColor;\n\
\n\
v_color = color;\n\
v_color.a *= translucency;\n\
v_splitDirection = splitDirection;\n\
}\n\
";
|