@jdultra/threedtiles 13.3.2 → 13.3.3

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.
@@ -7340,19 +7340,21 @@ void getVertexData(out vec3 position, out mat3 covariance) {
7340
7340
  int( (y + 0.5) ), // y pixel
7341
7341
  int( sliceIndex + 0.5 ) ); // z slice */
7342
7342
 
7343
- float index = float(order)+0.1; // add small offset to avoid floating point errors with modulo
7344
- float pixelsPerSlice = textureSize * textureSize;
7345
- float sliceIndex = floor(index / pixelsPerSlice);
7346
- float slicePixelIndex = mod(index,pixelsPerSlice);
7343
+
7344
+ highp uint uOrder = order; // Use a local uint copy
7347
7345
 
7348
- float x = mod(slicePixelIndex,textureSize);
7349
- float y = floor(slicePixelIndex / textureSize);
7346
+ // It's good practice to ensure textureSize is treated as uint for these calcs
7347
+ uint uTextureSize = uint(textureSize); // textureSize uniform is float
7348
+ uint uPixelsPerSlice = uTextureSize * uTextureSize;
7350
7349
 
7351
- //vec3 uvw = vec3((x + 0.5) / textureSize, (y + 0.5) / textureSize, (sliceIndex + 0.5) / numSlices);
7352
- ivec3 coord = ivec3(
7353
- int( (x + 0.5) ), // x pixel
7354
- int( (y + 0.5) ), // y pixel
7355
- int( sliceIndex + 0.5 ) ); // z slice
7350
+ uint sliceIndexVal = uOrder / uPixelsPerSlice;
7351
+ uint slicePixelIndex = uOrder % uPixelsPerSlice; // umod(uOrder, uPixelsPerSlice) also works
7352
+
7353
+ uint xVal = slicePixelIndex % uTextureSize; // umod(slicePixelIndex, uTextureSize)
7354
+ uint yVal = slicePixelIndex / uTextureSize;
7355
+
7356
+ // texelFetch takes ivec3 for coordinates, no +0.5 needed as these are direct integer indices
7357
+ ivec3 coord = ivec3(xVal, yVal, sliceIndexVal);
7356
7358
 
7357
7359
  // Position
7358
7360
  highp uvec4 positionColor = texelFetch(positionColorTexture, coord,0);