Hole, I’m using an example scene to create a texture from a screenshot and assign that texture to a material (diffuse and opacity). My problem is that every time I make a capture, the memory usage keeps increasing and I can’t clear the render buffer before making a new capture. Can someone give me a hand ?
Here I leave the access to the project, it is very simple.
If I hat to guess, it would be this part of your rendering code:
var colorBuffer = new pc.Texture(this.app.graphicsDevice, {
width: 512,
height: 512,
format: pc.PIXELFORMAT_R8_G8_B8_A8,
autoMipmap: true,
minFilter: pc.FILTER_NEAREST,
magFilter: pc.FILTER_NEAREST,
});
Since each time you click, you create a new texture, the browser will need to allocate RAM for it, and it won’t be cleared away until garbage collection occurs, since no other function clears it. You may want to define this texture in initialize and then instead of creating a new texture on screenshot, simply update the existing one with a new render. That should keep your memory usage under control.
If I’m wrong, other users on the forum please feel free to correct me.
Sorry for the late reply. Here are the changes to your renderLayerTotexture script that I made. Testing in Firefox showed that there was not an abnormal increase in RAM when changing the texture on the spheres repeatedly.
If this is not the behavior that you were looking for please feel free to reply. These changes were a bit quick and dirty, and more specialized help might be outside of the scope of what I can provide personally.