Hi,
I’m trying to load small images as textures that are not pre-determined at compile time, therefore, can’t quite use texture atlas as a solution. For efficiency, I was thinking of passing a dynamic array of images, convert these into TEXTURE_2D_ARRAY, and use a single-pass shader rendering.
Now, CubeTextures have restrictions and others (DataTexture, DataArrayTexture) are lower-level (work with image data). I’m trying to avoid brute-force rendering using individual textures as that could become expensive.
I want to know if a pattern similar to twgl.js can be cleverly implemented in THREE.js; something like .createTexture()
from images - relevant excerpt below:
const slices = [
"images/array/balloons.jpg",
"images/array/biggrub.jpg",
"images/array/curtain.jpg",
"images/array/hamburger.jpg",
"images/array/mascot.jpg",
"images/array/meat.jpg",
"images/array/orange-fruit.jpg",
"images/array/scomp.jpg",
"images/array/tif.jpg",
"images/array/手拭.jpg",
"images/array/竹輪.jpg",
"images/array/肉寿司.jpg",
];
const tex = twgl.createTexture(gl, {
target: gl.TEXTURE_2D_ARRAY,
src: slices,
});
Open to better approaches or workarounds.
Thanks in advance!