@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.
@@ -100,19 +100,21 @@ void getVertexData(out vec3 position, out mat3 covariance) {
100
100
  int( (y + 0.5) ), // y pixel
101
101
  int( sliceIndex + 0.5 ) ); // z slice */
102
102
 
103
- float index = float(order)+0.1; // add small offset to avoid floating point errors with modulo
104
- float pixelsPerSlice = textureSize * textureSize;
105
- float sliceIndex = floor(index / pixelsPerSlice);
106
- float slicePixelIndex = mod(index,pixelsPerSlice);
103
+
104
+ highp uint uOrder = order; // Use a local uint copy
107
105
 
108
- float x = mod(slicePixelIndex,textureSize);
109
- float y = floor(slicePixelIndex / textureSize);
106
+ // It's good practice to ensure textureSize is treated as uint for these calcs
107
+ uint uTextureSize = uint(textureSize); // textureSize uniform is float
108
+ uint uPixelsPerSlice = uTextureSize * uTextureSize;
110
109
 
111
- //vec3 uvw = vec3((x + 0.5) / textureSize, (y + 0.5) / textureSize, (sliceIndex + 0.5) / numSlices);
112
- ivec3 coord = ivec3(
113
- int( (x + 0.5) ), // x pixel
114
- int( (y + 0.5) ), // y pixel
115
- int( sliceIndex + 0.5 ) ); // z slice
110
+ uint sliceIndexVal = uOrder / uPixelsPerSlice;
111
+ uint slicePixelIndex = uOrder % uPixelsPerSlice; // umod(uOrder, uPixelsPerSlice) also works
112
+
113
+ uint xVal = slicePixelIndex % uTextureSize; // umod(slicePixelIndex, uTextureSize)
114
+ uint yVal = slicePixelIndex / uTextureSize;
115
+
116
+ // texelFetch takes ivec3 for coordinates, no +0.5 needed as these are direct integer indices
117
+ ivec3 coord = ivec3(xVal, yVal, sliceIndexVal);
116
118
 
117
119
  // Position
118
120
  highp uvec4 positionColor = texelFetch(positionColorTexture, coord,0);