-
-
Notifications
You must be signed in to change notification settings - Fork 23.7k
LightmapGI: Save directional lightmaps as ldr textures #100790
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
base: master
Are you sure you want to change the base?
Conversation
1e9c317 to
8a1c18c
Compare
|
After baking the lightmaps with this branch, am I supposed to see a separate |
Yes, the directional lightmap has a "_directional.png" suffix |
8a1c18c to
e16318f
Compare
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.
Tested locally, it works as expected in all rendering methods (both baking and rendering). Visuals are identical to before, and code looks good to me.
Testing project: test_lightmap_directional_ldr.zip
Note that right now, you need to bake lightmaps again for them to render correctly. This shouldn't be required anymore once a conversion tool is implemented.
This provides a significant size reduction for lightmap data that is committed to version control:
- Before: 93.4 MB EXR
- After: 23.5 MB EXR + 16.6 MB PNG = 40.1 MB (2.33x smaller)
Note that like shadowmask images, we could benefit from saving to a lossless WebP instead of PNG to reduce file sizes of what you commit to version control: #101881
However, this may be challenging to do unless directional data is stored at a halved texel density, since it will frequently go over WebP's 16383×16383 limit. For example, in the MRP, the directional data texture is 8192×24576.
Bake times are very similar before and after this PR (note that bake times include the time taken to reimport textures with VRAM compression).
Also, this paves the way for making #50574 usable with directional lightmaps, since directional data is no longer part of the main lightmap image.
PS: With this PR, we now have two lightmap textures that can go unused depending on which properties you end up disabling. For example, if you bake with shadowmasks and directional enabled, then disable both and bake again, both the shadowmask and directional textures will go unused but remain within the project files. We should look into printing a warning after baking when unused textures have been detected based on naming patterns. This would complement the existing Project > Tools > Orphan Resource Explorer dialog.
|
looks like it doesn't compile on master anymore servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp:3334:6: error: use of undeclared identifier 'u'
3334 | u.append_id(rd_texture); |
e16318f to
e21747c
Compare
Rebased, it should now compile. If possible, the lightmapper will now try to save the textures as .webp |
e21747c to
e9de058
Compare
|
Tested, Master: 24.69 MiB exr Visually seems to be identical in my test. An option to bake directional data at lower resolution would be incredibly useful, though this PR already puts directional lightmaps in a shippable range
Since the paths to the previous images are already stored in lightmap's |
|
While I was developing #107168 I tested on top of this PR quite extensively. Its visual fidelity always matched that of the hdr textures. |
e9de058 to
147bda9
Compare
|
Rebased on top of #107168, it's now ready for wider testing |
|
marked as draft since it's lacking conversion code for old lightmaps or simply because more testing is needed? |
147bda9 to
7fa08eb
Compare
7fa08eb to
317b878
Compare
|
This PR is now ready for initial feedback, though it's not fully complete as backwards compatibility needs to be added. |
317b878 to
f5fc2e0
Compare
|
I've added a way to upgrade older lightmaps - a new button will appear next to the "Bake" one for incompatible lightmaps, and pressing it will automatically convert the map to the new format |
|
I'm unable to reproduce the issue, on my end it converts fine. |
|
The conversion of the map is the same whether in compatibility or forward+ (works as expected), but rendering of the directional lightmaps is broken in compatibility. The weird blueish values only appear when using fog (depth fog) probably due to the negative values. will try and make an MRP |
|
Works as expected in my Sponza test scene |
|
set up the following MRP with a build from the master branch. When opened with a build from this PR, and after converting lightmaps, the rendering error I showed earlier is present in compatibility mode System Info: MRP: |
|
Does the issue go away when you add the directional light into the scene? Edit: This is fixed now |
f5fc2e0 to
3e64181
Compare
|
Tested with your updates and directional lightmaps are now rendered properly for compatibility in the test for me as well! For some reason adding a lightmapGI node with this branch still crashes the editor for me though |
3e64181 to
f7dd3a9
Compare
The crashing should be fixed now |
f7dd3a9 to
0da3e26
Compare
4ef4368 to
4988b9b
Compare
4988b9b to
9f8a331
Compare
9f8a331 to
5dd26fa
Compare




Depends on #100640
Inspired by https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/gdc2018-precomputedgiobalilluminationinfrostbite.pdf
Changes the way directional lightmap textures are stored: Previously they were part of the HDR lightmap texture array in spite of only storing LDR data. Now, they are saved as a separate .png file and compressed to DXT1/ETC2 RGB on import.
This approach reduces the memory footprint by half (when compressed as DXT1/ETC2 RGB). I've tested this with several scenes (many with a solid albedo, to see how the quality will be affected) and the low-quality versions don't look much worse than high-quality (BC7/ASTC 4x4) ones (even with etcpak).
#108405 will allow scaling them independently from regular lightmaps, making it possible to bake lower-resolution directional maps and save even more video memory.
TODO: