Hey hey
We are currently working on adding basis compression to our game. At one point during our charactersâ setup we are creating a custom texture atlas from multiple textures. We need to do this dynamicaly because of our customizer.
We did this by rendering each texture via pc.drawQuadWithShader
into our dynamic texture at a specific position. This works pretty well so far.
CopyAndDrawTexture.prototype.createTextureAtlas = function() {
var texture = this.textureAsset.resource;
const atlas = new pc.Texture(this.app.graphicsDevice, {
name: "copy",
width: texture.width,
height: texture.height,
format: texture.format,
mipmaps: false,
minFilter: pc.FILTER_LINEAR,
magFilter: pc.FILTER_LINEAR,
addressU: pc.ADDRESS_CLAMP_TO_EDGE,
addressV: pc.ADDRESS_CLAMP_TO_EDGE,
});
var renderTarget = new pc.RenderTarget({ colorBuffer: atlas, depth: false });
this.textureUniform.setValue(texture);
pc.drawQuadWithShader(
this.app.graphicsDevice,
renderTarget,
this.shader,
new pc.Vec4(0, 0, texture.width, texture.height)
);
renderTarget.destroy();
return atlas;
};
But when we activate basis compression on the individual textures, pc.drawQuadWithShader
throws the error âTypeError: Failed to execute âcompressedTexImage2Dâ on âWebGL2RenderingContextâ: parameter 7 is not of type âArrayBufferViewââ at line 434 in webgl-texture. Here the variable mipObject
(parameter 7) is null.
I also created a small reproduction project which creates this error, but also shows that it works if basis compression is disabled.
So we are wondering now, is this a bug, or are we missing some steps in our implementation? Is it even the right approach for basis compressed textures, or do we need to draw our textures in a different way into our dynamic texture?
Thanks for any kind of help