I have a program that works fine when my POT DataTextures are 1: 1 (width: height) in their texel size, however, when they are 2: 1 or 1: 2 in texel size, it seems that texels are erroneous to read and apply. I use continuous indexes (1,2,3,4,5 ...) to access texels using the two functions below.
I am wondering if something is wrong with how I access texel data, or maybe if my use of Float32Array for whole indices needs to be switched to Uint8Array or something else? Thanks in advance!
This function finds uv for textures that have one texel per particle cloud in my visualization:
float texelSizeX = 1.0 / uPerCloudBufferWidth;
float texelSizeY = 1.0 / uPerCloudBufferHeight;
vec2 perMotifUV = vec2(
mod(cellIndex, uPerCloudBufferWidth)*texelSizeX,
floor(cellIndex / uPerCloudBufferHeight)*texelSizeY );
perCloudUV += vec2(0.5*texelSizeX, 0.5*texelSizeY);
This function finds uv for textures containing one texel for each particle contained in all clouds:
float pTexelSizeX = 1.0 / uPerParticleBufferWidth;
float pTexelSizeY = 1.0 / uPerParticleBufferHeight;
vec2 perParticleUV = vec2(
mod(aParticleIndex, uPerParticleBufferWidth)*pTexelSizeX,
floor(aParticleIndex / uPerParticleBufferHeight)*pTexelSizeY );
perParticleUV += vec2(0.5*pTexelSizeX, 0.5*pTexelSizeY);