Deep clone a texture


I need to deep clone a texture so that the copied texture can be edited without altering other textures that link to the same underlying webgl texture.

texture.clone() seems to return a new texture object, but the underlying webgl texture is the same as the one that was cloned so when I change it other items in my scene change.

Is there a good way to make a full copy of a texture so the clone points to a unique underlying webgl texture?


cc @sebavan @Evgeni_Popov

You can try to use CustomProceduralTexture, maybe not a good solution, it do work.

Thanks for the nice idea :+1:, but I’m looking for a way to create a standard texture object so that I can manipulate it after it has been copied using UpdateTextureData. See Update just one channel of texture for context.


@tanpopo - thanks for the update, really cool implementation.

Also, reading the thread you linked to, I found the function TextureTools.CreateResizedCopy as mentioned by @bghgary here: Multiple cameras to generate multiple textures at the same time - #16 by bghgary which basically does the same thing.

Thanks again :smiley:

You also have the CopyTextureToTexture function: