Skip to content
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] CPU lightmapper environment energy fixes. #48089

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

JFonS
Copy link
Contributor

@JFonS JFonS commented Apr 22, 2021

@JFonS JFonS added this to the 3.4 milestone Apr 22, 2021
@JFonS JFonS requested a review from a team April 22, 2021 13:13
@JFonS JFonS requested a review from a team as a code owner April 22, 2021 13:13
@akien-mga akien-mga changed the title [3.2] CPU lightmapper environment energy fixes. [3.x] CPU lightmapper environment energy fixes. Apr 22, 2021
@akien-mga
Copy link
Member

Fixed a bug where ProceduralSky::get_panorama() returned a reference instead of a copy.

It's only used in BakedLightmap so it's probably fine (not exposed to the scripting API), but isn't it uncommon in Godot for a getter to actually return a copy instead of a reference?

PanoramaSky does have a public panorama property which is a reference as expected. Maybe ProceduralSky's getter should be get_panorama_copy() to avoid confusion?

@JFonS
Copy link
Contributor Author

JFonS commented Apr 22, 2021

Yeah, I added the function just so I could use it in BakedLightmap so the issue was only there.

The difference between PanoramaSky and ProceduralSky is that the former takes a user defined image and uses it, while ProceduralSky generates it from a set of parameters, so it should be read-only.

I think ProceduralSky::get_data() sounds better and aligns with Texture::get_data() which also returns a copy (although it was renamed to get_image() in master, so maybe PanoramaSky::get_image()??).

@akien-mga
Copy link
Member

I guess get_data() for 3.x and get_image() if there's an equivalent in master now or in the future :)

@JFonS
Copy link
Contributor Author

JFonS commented Apr 22, 2021

Makes sense, I will update the PR in a bit.

* Better handling of the scene's environment energy in the lightmapper
  bakes.
* Fixed a bug where ProceduralSky::get_panorama() returned a reference
  instead of a copy.
* Removed includes to Embree's internal header files.
@akien-mga akien-mga merged commit a86f546 into godotengine:3.x Apr 22, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.3.1.

@@ -1254,14 +1254,25 @@ Ref<Image> BakedLightmap::_get_irradiance_from_sky(Ref<Sky> p_sky, Vector2i p_si

sky_image->convert(Image::FORMAT_RGBF);
sky_image->resize(p_size.x, p_size.y, Image::INTERPOLATE_CUBIC);

if (p_energy != 1.0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With floating point numbers, should this be a tolerance test?
if (abs(p_energy - 1.0) > TOLERANCE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is only a shortcut optimization when the energy value is exactly 1, since x * 1 = x. Any other value would give a different result.

@JFonS JFonS deleted the cpulm_fixes branch May 4, 2021 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants