问题
My app for volume ray casting in WebGL is almost done. But i have found a problem. I have to simulate 3D texture by 2D texture. It is not problem. I am creating a huge texture from small slices. Dimensions of huge texture are about 4096x4096px. Problem is, that in some examples (it depends on number of slices) there is creating sth. like on the image bellow (i filled huge texture to white to be the fragment more visible).
I know that num of stripes depends on num of rows in huge texture. I am generating this texture near to 4096x4096px (but not exactly). It could be 4080x4060 etc. I think, problem is, that Three.js load my texture to gpu, but dont scale it to 4096x4096..so i am reading in fragment shader black color on the border of texture, because webgl work only with squared textures (512x512, 1024x1024... etc.). It caused black stripes in rendered image.
Problem is, that my Three.js app doesnt work with WebGL Inspector..so i am not sure.
Any idea how to fix that?
Thanks.
Tomáš
EDIT:
Ok, i have found problem..and "solution"...but solution didnt work good. I have 2 datasets. One is OK, second still the same error.
2 variants of code (each one works fine for one dataset but not for second) :
First)
dx = mod(slice, numColsInTexture) / numColsInTexture;
dy = 1.0 - (floor(slice / numColsInTexture) / numRowsInTexture);
Second)
dx = 1.0 - (mod(slice, numColsInTexture) / numColsInTexture);
dy = (floor(slice / numColsInTexture) / numRowsInTexture);
I really don't know, why it doesnt work for both datasets...i tried to dump GPU (WebGL inspector). Both textures are loaded valid on GPU (same orientation, same dimensions). Everything is same.
Please help me....thanks.
回答1:
Is your MIN and MAX filters of your texture set to NEAREST? And your WRAP[ST] set to CLAMP_TO_EDGE?
来源:https://stackoverflow.com/questions/15785838/texture-is-not-generated-valid-probably