Constructing CubeTextures in BabylonNative

I’m generating some texture data in a C++ app and I would like to construct a CubeTexture in BabylonNative to assign it to scene.environmentTexture and as a skybox. I originally planned to use RawCubeTexture, but it seems like it’s not implemented for BabylonNative. Is there a supported solution for this task? I see in the readme that only .env is supported.

I got something to work. If anyone wants some pointers, I extended NativeEngine to include a loadRawCubeTexture function, although the existing one probably works if you prepend an appropriate header (I’m guessing TGA is the easiest?). Then I created an InternalTexture with CubeRaw type, then pattern matched the setup from createRawTexture. The hard part that took a long time to track down was that the spherical polynomial computation doesn’t work in BabylonNative because “Reading cubemap faces is not supported” (This error gets swallowed, which is what made it time consuming to track down.). Instead, you can assign an irradianceTexture to the reflectionTexture and it won’t compute the polynomials. The last piece is that I had to set coordinatesMode to CUBIC_MODE since the default appears to select the same pixel coordinate in the cube map all the time.

1 Like

cc @BabylonNative

This would be great to fix. Can you help with a repro?

It would be great if you can contribute a fix for this, but if not, can you provide some code snippets of the implementation?