I’ve got a WebGLTexture which I would like to use in constructing a texture. There doesn’t seem to be any way to construct a new texture just from a WebGLTexture/matrix reference ( Using raw textures is unfortionatly out of the question ). I’ve attempted to manually override an existing texture’s underlying _webGLTexture, to no success: texture._texture._webGLTexture = myWebGLTexture;
Essentially, I have a BABYLON.Layer with isBackground enabled. I need to set it’s underling WebGLTexture to my own (specifically to a WebGLTexture that I have ).
You are not supposed to handle low level gl objects yourself, as doing it in parallel with Babylon will likely generates some problems… Maybe you can read the pixel data from this texture and create a proper Babylon texture from this?
Reading the pixel data and generating a Babylon texture is something that would impact performance too much in this use case as the texture updates every frame in an application that’s very performance dependant (hence going the low-level route).
I understand that updating internal gl texture would be considered ‘hacky’, but it seems to be the most performant way forward.
Ok, that should not work in 5.0, and it turns out that my solution does not work even in 4.2, it is in fact using the same InternalTexture than the ground instead of replacing _webGLTexture of the background… Will have another look tomorrow.