Texture VRAM consumption


#1

Hi guys, how it´s going?

I’m working on a project that I make a lot of changes textures from materials.
So after some changes my vram consumption is too high (something like > 4gb).
I tried destroy the ‘old’ texture before put the new one, but it’s not going as I expected.

Anyone had same issue or have any idea how to proceed? thanks!!!

Part of the code I make the changes:

ChangeMaterial.prototype.changeMaterial = function (mesh){        
    //Verify if can change the mesh material change
    if (this.allowChange(mesh.node.name)){    
        
        //New textures
        var selectedMaterial = pc.app.root.findByName('Cameras').script.cameraManager.selectedMaterial;            
        
        if (selectedMaterial !== undefined){        
                        
            //Clone the material to keep some properties, and create a new reference (I intend)
            var material = mesh.material.clone();
                                   
            if (material.diffuseMap){
                var tx = material.diffuseMap;
                material.diffuseMap = null;
                material.update();
                //destroy de current map (texture)
                tx.destroy();
            }
            
            //put the new map (texture)
            material.diffuseMap = selectedMaterial.DiffuseMap;
            
            material.bumpness = 0.25;            
            material.normalMap = selectedMaterial.NormalMap;
                                                
            if (selectedMaterial.Brilho < 80){
                //material.specular = pc.Color(0.162015503875969, 0.162015503875969, 0.162015503875969, 1);
                 material.specular =this.darkColor;
            }
            else{
                //material.specular = pc.Color(0.3803921568627451, 0.3803921568627451, 0.3803921568627451, 1); 
                material.specular = this.brigthColor;
            }            
            material.specularTint = true;
            
            material.specularMap = selectedMaterial.SpecularMap;
            
            material.shininess = selectedMaterial.Brilho;
                                
            material.update();            
            mesh.material = material;                                                  
            
        }
        
    }
};

#2

I want to know that as well