Create a new regular Texture with serialized texture url from previous step
Dispose the original DynamicTexture
Assign new regular Texture to a PBRMaterial
Render it…
When I am done rendering, dispose the regular Texture
By comparing these 2 processes. Which one is more memory efficient? Including overall memory usage as well as peak memory usage?
Feels like serializations seams more efficient since it has the less usage of html5 canvas? Is it possible for different browsers (for example, Chrome vs Safari), the answer could be different?
I’d say approach 2 would be more CPU efficient, but I’m not sure about memory… I think this needs to be tested in practice and it’s very possible that the results would differ browser by browser. I made a test here: Dynamic Texture Example | Babylon.js Playground (babylonjs.com) but I’m not sure if this would be the best way to test, maybe @Evgeni_Popov has an idea?
Peak memory will be the same as you use a dynamic texture in both cases. In case 2, as you dispose the dynamic texture, you will save a little bit of memory, but it will probably won’t make a big difference with case 1. If you are really very tighly limited by memory, you can use case 2, else case 1 is ok and is easier to setup.
I was also thinking of doing the serialization process offline and store the serialized textures on server. But found the serialized texture string is quite big in size. My original source textures for dynamic texture is ~200KB but the serialized string file is ~5MB. So this offline serializing idea might not a good one in practice.