-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Add support for saving multiple Images in BakedLightmap #58102
Conversation
I tried this on Reflection, but the resulting bake looks broken: When atlas generation is disabled, it looks correct: Testing project: test_lightmap_large_3.x.zip |
I force-pushed a fix for @Calinou's issue, everything should be working now. |
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); | ||
// -- GODOT start -- | ||
// rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); | ||
rects[i].was_packed = !(rects[i].x == (int) STBRP__MAXVAL && rects[i].y == (int) STBRP__MAXVAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you PR that fix upstream too?
core/math/geometry.cpp
Outdated
@@ -36,6 +36,7 @@ | |||
#include "thirdparty/misc/clipper.hpp" | |||
#include "thirdparty/misc/triangulator.h" | |||
#define STB_RECT_PACK_IMPLEMENTATION | |||
#define STBRP_LARGE_RECTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting that stb_rect_pack 1.01 would make this the default behavior (we have 1.00): https://github.com/nothings/stb/blob/af1a5bc352164740c1cc1354942b1c6b72eacb8a/stb_rect_pack.h#L44
Instead of fitting all atlas slices into a single image, which meant there was a hard limit on the size, BakedLightmap will now save as many images as needed to fit all the slices generated by the lightmapper.
@akien-mga Since updating to 1.01 fixes both changes I had made in this PR, I just removed them and we can do the upgrade in a separate PR. |
Thanks! |
Looks awesome! |
Supporting multiple atlases makes it possible to successfully bake lightmaps in large levels without exceeding the maximum texture size. Before multiple atlases were supported, you had to disable atlases to successfully bake lightmaps in a large scene. This was less efficient to render and resulted in a lot of files being created when baking lightmaps. |
Doesn't work in 3.5 RC2. |
@gdlq Please open a new issue with a minimal reproduction project attached. |
Instead of fitting all atlas slices into a single image, which meant there was a hard limit on the size,
BakedLightmap
will now save as many images as needed to fit all the slices generated by the lightmapper.I only did some quick testing on a single scene, so it would be good to get this tested on more scenarios before merging.
The size limit is much less of an issue in
master
since the maximum size for images is much larger there. Still, once we see everything is working fine in3.x
, this can be forward-ported tomaster
.Closes #51741, implements godot-proposals#2147.