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

LightmapGI: Lightmaps with UV2 imported from Blender are broken on 4.4 Beta1 #102164

Closed
Tracked by #56033
SpockBauru opened this issue Jan 29, 2025 · 4 comments · Fixed by #102497
Closed
Tracked by #56033

LightmapGI: Lightmaps with UV2 imported from Blender are broken on 4.4 Beta1 #102164

SpockBauru opened this issue Jan 29, 2025 · 4 comments · Fixed by #102497

Comments

@SpockBauru
Copy link

Tested versions

Reproducible in: 4.4.beta1
Not Reproducible in: 4.3 stable and 4.4 dev7

System information

Godot v4.4.beta1 - Windows 11 (build 22631) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 32.0.15.6614) - 12th Gen Intel(R) Core(TM) i7-12700KF (20 threads)

Issue description

Follow up from #101391, according to @Geometror this seems to be another issue unrelated to the crash.

When baking the tunnel from the follow MRP, which has UV2 imported from Blender, Lightmaps get corrupted on 4.4.beta1.

This issue doesn't happen on 4.3 stable neither 4.4.dev7.

It seems to bake correctly until the ShadowMask PR (189c8eb) but not on the transparency PR (a3525bc)

Steps to reproduce

Bake the lighmaps on the MRP.

Expected: Tunnel is dark with interior lights.
Results: Tunnel is light with weird lights.

Example:

4.3 stable 4.4.beta1
Image Image

Minimal reproduction project (MRP)

This MRP contains the .glb file from the tunnel and the test scene.
lightmap-regression.zip

@AThousandShips AThousandShips added this to the 4.4 milestone Jan 30, 2025
@AThousandShips AThousandShips moved this from Unassessed to Release Blocker in 4.x Release Blockers Jan 30, 2025
@Calinou Calinou changed the title [LightmapGI] Lightmaps with UV2 imported from Blender are broken on 4.4 Beta1 LightmapGI: Lightmaps with UV2 imported from Blender are broken on 4.4 Beta1 Jan 30, 2025
@Geometror
Copy link
Member

Geometror commented Jan 30, 2025

(Partially) copied and extended from #101391 (comment)

I investigated the issue (using the lightmap debug textures) and saw that the lightmap UV2 albedo and emission textures don't match the rest (position/normal/etc.). By that I mean the scale/position in the texture as well as individual UV2 islands for some reason.

I can reproduce this in 4.3 by adding emission to the surface materials of the tunnel. It looks like this has been an unnoticed problem for a long time and the transparency support "revealed" it because we actually check for surface transparency when tracing rays (not just any hits) using the alpha channel of the broken albedo texture.
In the shader albedo/emission and position/normal/etc. textured are sampled the exact same way, so most of the surface becomes transparent. After manually adjusting the UV2 offset and scale in the scene shader for the material uv2 mode (scene_forward_clustered.glsl; line 655), it was almost fixed. Almost, because a simple affine transformation isn't enough. There appears to be something weird going on when blitting of meshes into the atlas.

Albedo Position
Image Image

Note

If you look closely at the left picture, you can see that it is not even an affine transformation of the right, it's actually different (look at the space between the floor and wall parts, or the tunnel entrance)

The comparisons below are in the "Display Lightning" mode. I used a stripped down version of the original MRP from the other issue, where there's only the tunnel with both surfaces having different emission colors:

Image

Notice how the emission texture is completely off here as well Now most of the tunnel is transparent for the lightmapper since the albedo texture doesn't match
Image Image

@BlueCube3310
Copy link
Contributor

This is an issue with rendering the textures using the UV2 channel:

Image

It looks like it's rendered at 1/4 its intended size

@BlueCube3310

This comment has been minimized.

@BlueCube3310
Copy link
Contributor

#102497 should fix this, please let me know whether it works as intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Very Bad
Development

Successfully merging a pull request may close this issue.

5 participants