diff --git a/cocos/core/renderer/scene/skybox.ts b/cocos/core/renderer/scene/skybox.ts index 686f69e848..82a59cdd6e 100644 --- a/cocos/core/renderer/scene/skybox.ts +++ b/cocos/core/renderer/scene/skybox.ts @@ -376,15 +376,14 @@ export class Skybox { skybox_material.setProperty('environmentMap', envmap); skybox_material.recompileShaders({ USE_RGBE_CUBEMAP: this.isRGBE }); } - } - - if (this._model) { - if (this._editableMaterial) { - this._model.setSubModelMaterial(0, this._editableMaterial); - } else { - this._model.setSubModelMaterial(0, skybox_material!); + if (this._model) { + if (this._editableMaterial) { + this._model.setSubModelMaterial(0, this._editableMaterial); + } else { + this._model.setSubModelMaterial(0, skybox_material!); + } + this._updateSubModes(); } - this._updateSubModes(); } } diff --git a/native/cocos/scene/Skybox.cpp b/native/cocos/scene/Skybox.cpp index 066067bb87..5396ec2a22 100644 --- a/native/cocos/scene/Skybox.cpp +++ b/native/cocos/scene/Skybox.cpp @@ -355,11 +355,11 @@ void Skybox::updatePipeline() const { } _material->setProperty("environmentMap", envmap); _material->recompileShaders({{"USE_RGBE_CUBEMAP", isRGBE()}}); - } - if (_model != nullptr && _material != nullptr) { - _model->setSubModelMaterial(0, _material); - updateSubModes(); + if (_model != nullptr) { + _model->setSubModelMaterial(0, _material); + updateSubModes(); + } } Root *root = Root::getInstance(); @@ -424,11 +424,6 @@ void Skybox::updatePipeline() const { valueChanged = true; } - //set the macro value first before update the material - if (isEnabled() && _material != nullptr) { - _material->recompileShaders({ {"USE_RGBE_CUBEMAP", isRGBE()} }); - } - if (_model != nullptr && _material != nullptr) { _model->setSubModelMaterial(0, _material); }