Skip to content

Commit 314c729

Browse files
ibothaYuriSizov
authored andcommitted
Fix issue 74259 by setting the sky cover property back to nil when it is reset in the editor.
(cherry picked from commit 74041e3)
1 parent 9307d85 commit 314c729

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

scene/resources/sky_material.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ float ProceduralSkyMaterial::get_sky_energy_multiplier() const {
7474

7575
void ProceduralSkyMaterial::set_sky_cover(const Ref<Texture2D> &p_sky_cover) {
7676
sky_cover = p_sky_cover;
77-
RID tex_rid = p_sky_cover.is_valid() ? p_sky_cover->get_rid() : RID();
78-
RS::get_singleton()->material_set_param(_get_material(), "sky_cover", tex_rid);
77+
if (p_sky_cover.is_valid()) {
78+
RS::get_singleton()->material_set_param(_get_material(), "sky_cover", p_sky_cover->get_rid());
79+
} else {
80+
RS::get_singleton()->material_set_param(_get_material(), "sky_cover", Variant());
81+
}
7982
}
8083

8184
Ref<Texture2D> ProceduralSkyMaterial::get_sky_cover() const {
@@ -365,8 +368,11 @@ ProceduralSkyMaterial::~ProceduralSkyMaterial() {
365368

366369
void PanoramaSkyMaterial::set_panorama(const Ref<Texture2D> &p_panorama) {
367370
panorama = p_panorama;
368-
RID tex_rid = p_panorama.is_valid() ? p_panorama->get_rid() : RID();
369-
RS::get_singleton()->material_set_param(_get_material(), "source_panorama", tex_rid);
371+
if (p_panorama.is_valid()) {
372+
RS::get_singleton()->material_set_param(_get_material(), "source_panorama", p_panorama->get_rid());
373+
} else {
374+
RS::get_singleton()->material_set_param(_get_material(), "source_panorama", Variant());
375+
}
370376
}
371377

372378
Ref<Texture2D> PanoramaSkyMaterial::get_panorama() const {
@@ -558,8 +564,11 @@ bool PhysicalSkyMaterial::get_use_debanding() const {
558564

559565
void PhysicalSkyMaterial::set_night_sky(const Ref<Texture2D> &p_night_sky) {
560566
night_sky = p_night_sky;
561-
RID tex_rid = p_night_sky.is_valid() ? p_night_sky->get_rid() : RID();
562-
RS::get_singleton()->material_set_param(_get_material(), "night_sky", tex_rid);
567+
if (p_night_sky.is_valid()) {
568+
RS::get_singleton()->material_set_param(_get_material(), "night_sky", p_night_sky->get_rid());
569+
} else {
570+
RS::get_singleton()->material_set_param(_get_material(), "night_sky", Variant());
571+
}
563572
}
564573

565574
Ref<Texture2D> PhysicalSkyMaterial::get_night_sky() const {

0 commit comments

Comments
 (0)