Hey,
I really can’t seem to change a Materials cubemap by code.
I tried setting material.cubeMap, material.envAtlas, material.prefilteredCubemaps, nothing seems to work.
Here is what I’m doing:
When I remove the prefilterd data from the cubemap, it seems it’s reflecting the environment but not lighting it.
Here is a sample project: https://playcanvas.com/editor/scene/1600264
ChangeCubemap.prototype.changeCubeMap = function (name) {
const mapAsset = this.app.assets.find(name, 'cubemap');
// Use the high quality reflection if the faces are loaded otherwise
// use the next prefiltered texture
if (mapAsset.resource) {
this._material.cubeMap = mapAsset.resource;
} else {
this._material.cubeMap = mapAsset.resources[1];
}
if (mapAsset.resources[1]) {
const envAtlas = pc.EnvLighting.generatePrefilteredAtlas(mapAsset.resources.slice(1));
this._material.envAtlas = envAtlas;
} else {
this._material.envAtlas = null;
}
this._material.update();
};
The part where I assign a cubemap a prefiltered texture feels weird to me and will need to ask about it
Thanks, that works for me.
generatePrefilteredAtlas did the magic here.
P.S.: While I’m here I might as well mention that it would be handy to have a intensity / exposure slider as with the skybox either in the material or the cubemap itself.