Expose Lightmap Baking#1293
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
WalkthroughAdds an internal ChangesLightmapGI bake API rework
Lightmapper module build and TOOLS_ENABLED gating
Sequence Diagram(s)sequenceDiagram
participant LightmapGIEditorPlugin
participant LightmapGI
participant ResourceLoader
participant ResourceSaver
LightmapGIEditorPlugin->>LightmapGI: _bake(from_node, image_data_path, bake_step)
LightmapGI->>ResourceLoader: import(atlas_path)
LightmapGI->>ResourceSaver: save(Texture2DArray, atlas_path)
LightmapGI->>LightmapGIEditorPlugin: return BakeError
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
modules/lightmapper_rd/lightmapper_rd.cpp (1)
2104-2138: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick winFix the non-
TOOLS_ENABLEDfallback inmodules/lightmapper_rd/lightmapper_rd.cpp
modules/lightmapper_rd/SCsubadds this source unconditionally, andmodules/lightmapper_rd/config.pyallows the module in non-editor builds. In that path, the#elsebranch insideif (p_bake_shadowmask)is wrong: it calls_denoise(...)withoutunocclude_texand useslight_accum_texinstead ofshadowmask_tex, so export-template builds with this module enabled will fail here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@modules/lightmapper_rd/lightmapper_rd.cpp` around lines 2104 - 2138, The non-TOOLS_ENABLED fallback in the shadowmask denoise path is incorrect and will break non-editor builds. In the `lightmapper_rd.cpp` bake flow, fix the `#else` branch inside `if (p_bake_shadowmask)` so it uses the shadowmask textures and the same `_denoise(...)` signature expected there, including the `unocclude_tex` argument where required. Ensure the fallback mirrors the `denoiser == 1`/built-in branches’ data flow for `shadowmask_tex` and `shadowmask_tex2`, rather than reusing `light_accum_tex`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@doc/classes/LightmapGI.xml`:
- Around line 18-29: Update the LightmapGI.bake documentation wording so it
matches the actual return type and behavior: the method returns a
LightmapGI.BakeError int, not images. In the description for bake, replace the
headless-editor note in a way that refers to the bake result/return value being
null or invalid rather than “the images returned,” and keep the wording
consistent with the bake() method’s existing return semantics.
In `@scene/3d/lightmap_gi.cpp`:
- Around line 870-872: The non-editor bake path in `Lightmapper::bake` is
reusing the wrong image set and skipping the supersampling downsample. Move the
`texture_image->resize(...)` supersampling downsample so it runs for runtime
bakes too, not only under `is_editor_hint()`, and update
`texs->create_from_images(...)` to use the per-texture subset of `images` that
was assembled for each `texture_image` instead of the full vector. Use the
existing slice grouping logic around `images`, `texture_count`, and
`slices_per_texture` so each `r_textures[i]` contains only its own slices and
matches `lightmapper->get_bake_mesh_texture_slice(i)`.
- Around line 884-887: The atlas reimport path in LightmapGI::bake/lightmap
update flow ignores the return value of ResourceLoader::import(atlas_path),
which can hide a failed reimport behind a cached ResourceLoader::load result.
Check the Error from ResourceLoader::import first in the same block that loads
the TextureLayered, and if it is not OK, fail early with
LightmapGI::BAKE_ERROR_CANT_CREATE_IMAGE before attempting to load the texture.
- Around line 845-869: The import-preservation check in the lightmap atlas
export path is ineffective because the existing .import file is never loaded
before updating the ConfigFile. In the atlas save flow inside the lightmap GI
bake logic, restore loading of config_path into the ConfigFile before calling
has_section_key and set_value so existing import settings are read first; then
keep the conditional update for compress/mode in the same block so
user-customized values are not overwritten.
- Around line 1289-1298: The ENVIRONMENT_MODE_CUSTOM_SKY handling in
lightmap_gi.cpp restores the sky radiance size unconditionally, unlike the
ENVIRONMENT_MODE_SCENE path that only restores when the value was actually
changed. Update the custom-sky branch in the same way: track whether
`environment_custom_sky->set_radiance_size(...)` was applied, and only call
`set_radiance_size(old_radiance_size)` when the size was modified so editor
bakes do not trigger unnecessary recomputation.
---
Outside diff comments:
In `@modules/lightmapper_rd/lightmapper_rd.cpp`:
- Around line 2104-2138: The non-TOOLS_ENABLED fallback in the shadowmask
denoise path is incorrect and will break non-editor builds. In the
`lightmapper_rd.cpp` bake flow, fix the `#else` branch inside `if
(p_bake_shadowmask)` so it uses the shadowmask textures and the same
`_denoise(...)` signature expected there, including the `unocclude_tex` argument
where required. Ensure the fallback mirrors the `denoiser == 1`/built-in
branches’ data flow for `shadowmask_tex` and `shadowmask_tex2`, rather than
reusing `light_accum_tex`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 09f48f42-d011-4de3-8a22-76daf7835335
📒 Files selected for processing (7)
doc/classes/LightmapGI.xmleditor/scene/3d/lightmap_gi_editor_plugin.cppmodules/lightmapper_rd/config.pymodules/lightmapper_rd/lightmapper_rd.cppmodules/xatlas_unwrap/config.pyscene/3d/lightmap_gi.cppscene/3d/lightmap_gi.h
41c920a to
5817262
Compare
5817262 to
ac7cf93
Compare
|
So looks like this is cleaned up, but I'm not sure what sourcelocation meant by this in the original PR: module_lightmapper_rd_enabled build parameter has to be enabled for runtime baking to work Those aren't valid flags for scons when I try to build it. |
This is strictly copying the code from the following PR so we can get it in with the changes that have occurred since:
#8
Summary by CodeRabbit
from_nodeand optionalimage_data_path.