【发布时间】:2017-10-02 20:57:28
【问题描述】:
当我的 POT DataTexture 的纹素尺寸为 1:1(宽度:高度)时,我有一个运行良好的程序,但是当它们的纹素尺寸为 2:1 或 1:2 时,纹素似乎不正确阅读并应用。我正在使用连续索引 (1,2,3,4,5...) 来使用以下两个函数访问纹素。
我想知道我访问纹素数据的方式是否有问题,或者我对整数索引的 Float32Array 使用是否需要切换到 Uint8Array 或其他什么?提前致谢!
这个函数在我的可视化中找到每个粒子云一个纹素的纹理的 uv:
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);
此函数为所有云中包含的每个粒子找到一个纹理像素的 uv:
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);
【问题讨论】:
标签: three.js textures webgl shader