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.
We tend to hide the internal data to protect our capability to update without breaking backward compat.
That being said, in that case you can still call groundMaterial.diffuseTexture.getInternalTexture() to get access to internal data if you REALLY want to
Hi @Deltakosh In my case I want to retrieve the internal WebGLTexture from BABYLON.Texture, in order to use that texture with CesiumJS or other native WebGL apps.
By now I am using Texture.getInternalTexture()._hardwareTexture._webGLTexture to achieve this, so I wonder whether it’s possible to offer some public methods.
Thank you @sebavan, I am also using engine.wrapWebGLTexture() somewhere else for the inverse operation XD