Re-loading cubemap fails

Hey,

Loading a cubemap asset at runtime (with neither the cubemap nor associated textures being pre-loaded) works wonderfully, by just the simple command:

this.app.assets.load(cubemapAsset);

This also automatically loads all the associated textures that are necessary.

However if said cubemap and associated textures are unloaded again using

texture1.unload();
texture2.unload();
...
texture6.unload();
cubemapAsset.unload();

And I try to reload and apply the cubemap again using the first method, it fails. Based on the errors and some digging I did, it seems it does not load the associated textures the 2nd time, leading to failure when trying to render it.

Anyone experienced the same, and found an elegant solution?

While I was making this project PlayCanvas 3D HTML5 Game Engine I also found that issue with cubemap assets. Also unloading a font asset and reloading also causes issues probably due to the generated font texture.

Unfortunately I don’t have a solution for either other than just not unloading.

Hm… ic… That’s inconvenient.

Another workaround I found that works is to keep track of the texture assets and make sure to re-load them manually before applying the cubemap. However, this is pretty inconvenient as well.

Lets see, unless someone else post a better solution I think I’ll make a feature request to make this process automated :slight_smile:

2 Likes

What I tend to do is tag all the cubemap assets and it’s 6 faces together so it’s easier to unload and load using asset registry find by tag

@slimbuck doesn’t the engine support a loading a single equirectangular texture for environment maps now? Is that supported in the editor?

Yeah… that does make it easier.
Still, this behaviour seems kinda… inconvenient, and not what I would expect. So I added a request here in the repo. Not exactly a high pri I imagine, but nice to have it there I think :slight_smile:

1 Like

I’ve responded on the ticket @Astra. Hopefully we have a simple fix there.

1 Like

I saw!
Thx for looking into it! :grin: