14 lines
588 B
GLSL
14 lines
588 B
GLSL
vec2 getLookupUv(vec2 dimensions, int i) {
|
|
int pixY = i / int(dimensions.x);
|
|
int pixX = i - (pixY * int(dimensions.x));
|
|
float pixelWidth = 1.0 / dimensions.x;
|
|
float pixelHeight = 1.0 / dimensions.y;
|
|
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
|
|
float v = (float(pixY) + 0.5) * pixelHeight;
|
|
return vec2(u, v);
|
|
}
|
|
|
|
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {
|
|
vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
|
|
return texture(extentsTexture, getLookupUv(textureDimensions, index));
|
|
} |