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
Implement bicubic sampling for lightmaps #89919
base: master
Are you sure you want to change the base?
Conversation
We're unable to approve for merge if the github actions is failing. https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html |
e533ddb
to
9151cba
Compare
The bicubic sampling is adding artifacts around the edges of the boxes in the second example? |
Unfortunately yes, this sort of light bleeding happens with low-resolution lightmaps (3 x 256 x 256 for 38 meshes in this case). |
59e4bb9
to
3f80ace
Compare
The filtering can now be toggled from the ProjectSettings and the lightmaps are backwards-compatible with older ones, so upgrading should be seamless. |
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 (rebased on top of master
29b3d9e), it works as expected in all rendering methods. Code looks good to me at a glance.
Toggling the project setting works without having to restart the project as well, which is nice for providing graphics options in projects. (This is an upgrade from 3.x where a restart was required when using GLES2, but not GLES3.)
Disabled | Enabled |
---|---|
PS: I noticed toggling bicubic filtering works on existing projects with lightmaps that were baked without this PR. They seem to look fine in this scenario, though I haven't looked extensively to see if they suffer more from lightmap bleeding when bicubic filtering is enabled compared to lightmaps baked with this PR.
Should we print a warning when bicubic filtering is enabled and a LightmapGIData lacks texture size information?
Also, note that this PR prevents using lightmaps baked after this PR is merged from working in older builds not including this PR. The scene will still load but lightmaps won't display until you bake lightmaps again. It's not a dealbreaker, just worth keeping in mind.
If the texture size information isn't present in the file, it's taken from the lightmap textures instead. |
Co-authored-by: Calinou <hugo.locurcio@hugo.pro>
3f80ace
to
b2c0b0d
Compare
@@ -2474,6 +2474,7 @@ void RenderingServer::_bind_methods() { | |||
ClassDB::bind_method(D_METHOD("light_directional_set_sky_mode", "light", "mode"), &RenderingServer::light_directional_set_sky_mode); | |||
|
|||
ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter); | |||
ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "filter"), &RenderingServer::lightmaps_set_bicubic_filter); |
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.
ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "filter"), &RenderingServer::lightmaps_set_bicubic_filter); | |
ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "enable"), &RenderingServer::lightmaps_set_bicubic_filter); |
To match the docs. Might also be worth changing the C++ methods argument from p_use
to p_enable
for consistency, but it's not required.
<description> | ||
Adds an object that is considered baked within this [LightmapGIData]. | ||
Adds an object that is considered baked within this [LightmapGIData]. [param texture_size] must match the size of the [i]entire[/i] lightmap texture, which is used for bicubic filtering when rendering the lightmap. |
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.
Adds an object that is considered baked within this [LightmapGIData]. [param texture_size] must match the size of the [i]entire[/i] lightmap texture, which is used for bicubic filtering when rendering the lightmap. | |
Adds an object that is considered baked within this [LightmapGIData]. [param texture_size] must match the size of the [i]entire[/i] lightmap texture which is used for bicubic filtering when rendering the lightmap. |
No break here in English I'd say
You will also need to add compatibility binds |
Supersedes #77912
Closes #49935
Adds support for bicubic sampling in LightmapGI, which results in much smoother-looking baked shadows:
To do: