RenderLayerTotexture.prototype.setRenderTarget = function () {
// var x = this.app.scene.layers.getLayerByName(this.layerName);
var x = this.app.root.findByName('MirrorCamera').camera
if (x && !x.renderTarget) {
var tex = new pc.Texture(this.app.graphicsDevice, {
addressU: pc.ADDRESS_CLAMP_TO_EDGE,
addressV: pc.ADDRESS_CLAMP_TO_EDGE,
width: 512,
height: 512,
format: pc.PIXELFORMAT_RGBA32F,
autoMipmap: true,
});
tex.minFilter = pc.FILTER_LINEAR;
tex.magFilter = pc.FILTER_LINEAR;
tex.name = this.layerName;
var opts = {
depth: true,
depthBuffer: new pc.Texture(this.app.graphicsDevice, {
format: pc.PIXELFORMAT_DEPTHSTENCIL,
width: tex.width,
height: tex.height
})
};
console.log(x)
var targ = new pc.RenderTarget(this.app.graphicsDevice, tex, opts);
x.renderTarget = targ;
console.log(tex)
console.log(targ)
}
}
The playcanvas.js version I am using is 1.64.4
I created a texture object as a color buffer for the rendering target, and a depth texture as a depth buffer for the rendering target. Finally, associate the rendering target with the layer object, so that the layer’s rendering results can be output to the specified texture.
Console error
[.WebGL-000064C401FBEA00] GL_INVALID_OPERATION: Texture format does not support mipmap generation.
After checking the document, it was found that renderTarget was set on the camera component and still reported an error
Can someone help me solve it? Thank you very much