Skip to content

Commit 1da8a2a

Browse files
committed
Merge pull request godotengine#97416 from Calinou/lightmapgi-check-rendering-device-availability
Check RenderingDevice availability to display LightmapGI configuration warnings
2 parents 34913f2 + 0807d60 commit 1da8a2a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

editor/plugins/lightmap_gi_editor_plugin.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,23 @@ LightmapGIEditorPlugin::LightmapGIEditorPlugin() {
179179
// when the editor theme updates.
180180
bake->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Bake"), EditorStringName(EditorIcons)));
181181
bake->set_text(TTR("Bake Lightmaps"));
182+
183+
#ifdef MODULE_LIGHTMAPPER_RD_ENABLED
184+
// Disable lightmap baking if not supported on the current GPU.
185+
if (!DisplayServer::get_singleton()->can_create_rendering_device()) {
186+
bake->set_disabled(true);
187+
bake->set_tooltip_text(vformat(TTR("Lightmap baking is not supported on this GPU (%s)."), RenderingServer::get_singleton()->get_video_adapter_name()));
188+
}
189+
#else
190+
// Disable lightmap baking if the module is disabled at compile-time.
191+
bake->set_disabled(true);
192+
#if defined(ANDROID_ENABLED) || defined(IOS_ENABLED)
193+
bake->set_tooltip_text(vformat(TTR("Lightmaps cannot be baked on %s."), OS::get_singleton()->get_name()));
194+
#else
195+
bake->set_tooltip_text(TTR("Lightmaps cannot be baked, as the `lightmapper_rd` module was disabled at compile-time."));
196+
#endif
197+
#endif // MODULE_LIGHTMAPPER_RD_ENABLED
198+
182199
bake->hide();
183200
bake->connect(SceneStringName(pressed), Callable(this, "_bake"));
184201
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);

scene/3d/lightmap_gi.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,17 @@ Ref<CameraAttributes> LightmapGI::get_camera_attributes() const {
16021602
PackedStringArray LightmapGI::get_configuration_warnings() const {
16031603
PackedStringArray warnings = VisualInstance3D::get_configuration_warnings();
16041604

1605-
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
1606-
warnings.push_back(RTR("Lightmap can only be baked from a device that supports the RD backends. Lightmap baking may fail."));
1605+
#ifndef MODULE_LIGHTMAPPER_RD_ENABLED
1606+
#if defined(ANDROID_ENABLED) || defined(IOS_ENABLED)
1607+
warnings.push_back(vformat(RTR("Lightmaps cannot be baked on %s. Rendering existing baked lightmaps will still work."), OS::get_singleton()->get_name()));
1608+
#else
1609+
warnings.push_back(RTR("Lightmaps cannot be baked, as the `lightmapper_rd` module was disabled at compile-time. Rendering existing baked lightmaps will still work."));
1610+
#endif
1611+
return warnings;
1612+
#endif
1613+
1614+
if (!DisplayServer::get_singleton()->can_create_rendering_device()) {
1615+
warnings.push_back(vformat(RTR("Lightmaps can only be baked from a GPU that supports the RenderingDevice backends.\nYour GPU (%s) does not support RenderingDevice, as it does not support Vulkan, Direct3D 12, or Metal.\nLightmap baking will not be available on this device, although rendering existing baked lightmaps will work."), RenderingServer::get_singleton()->get_video_adapter_name()));
16071616
return warnings;
16081617
}
16091618

0 commit comments

Comments
 (0)