-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
lightmap visual glitches #85730
Comments
Sounds like it might be similar to this if you're using primitive meshes instead of OBJ imports. We couldn't determine much but it seemed like the UV2 generation had some issues that were exposed by the half pixel offset, which in turn fixed the issues present in OBJ imports. Are you using primitive meshes or OBJ meshes? |
the wall/floor/ceiling meshes are made in Blender and imported as .glb files. |
Does it get fixed if you let Godot auto-generate the UV2 instead? I'm wondering if a discrepancy has popped up between both of them. |
Did you re-bake the lighting after auto-generating the UV2s? |
didn't try originally. after trying and using auto-generated for wall/floor/ceil meshes:
|
That's a lot of different issues so I'd try ruling them out one by one to see if we can find any actual issue caused by the lightmapper. Let's start with the first one, as I've explained in other issues, lightmapping is pretty much the enemy of kitbashing if you push really low resolutions and it looks like those tiles on the walls are all individual meshes. It's like trying to get two blurry textures to match across two planes, it's pretty much never gonna look right. Does the issue of the first picture get alleviated if you increase the resolution (by modifying their texel size)? As for the original issues, I think it reveals there's a discrepancy between whatever tool was used to generate the UV2 and what Godot seems to be expecting, although I'm not sure about saying who's in the right without seeing the mapping itself in numerical detail. |
Please upload a minimal reproduction project1 to make this easier to troubleshoot. Footnotes
|
here's the scene that causes trouble (too big for github upload): |
disabling "use texture for bounces" fixed the black rectangles, so this feature is bugged. perhaps it's related to the scene's size? |
That feature isn't bugged, it's a shortcut option. Normally when computing samples the tracer can choose to grab the light data that was computed on the first light pass or compute it from scratch. Disabling is more accurate but much slower on scenes with multiple lights. If disabling helps you out then that's for the best, but it probably indicates your lightmap resolution is too low or your UVs are too stretched if it's making a significant impact. From the docs:
|
Sorry, I mistakenly edited your comment instead of replying. Will reply in a bit. |
That's what I mean by the fact the flag isn't bugged. The flag itself enables the behavior of the tracer to take this shortcut and sample the texture. If for whatever reason the texture sampling itself is wrong, that error will carry over. That's why I said the feature itself isn't broken, it's just carrying over the error from another step. However it sounds like it was unrelated if you can't reproduce it, so I think I'm still with the theory that the coordinates are at fault in one of the iterations you've tested of this. |
here's a minimal reproducible case: looking at the generated lightmap it seems like pixels at the edges are shifted, possibly mismatching their UV coordinates? |
Changing the texel size in project settings (the one for primitive meshes) to 0.05, and regenerating the UV2s of the primitive box, gives a texel density that seems to match up exactly with the imported model. However, the artifacts in the corners and on the edges reappeared. Kinda seems like this might be happening: #69126 (comment) . |
the linked comment seems to suggest it's texture bleeding due to wrong UVs. while it's probably not the problem as the generated UVs include padding, I will mention the following just to be safe: higher resolution will make the texture bleeding smaller and/or less likely to happen, but it's still there and there's still a bug. also the shifted lightmap pixels are still a possible source for problems, possibly making the UV coordinate problem worse. |
The reason I'm inclined to believe this is a UV issue is because I can't really spot any substantial difference in the bake results between the imported cubes and primitive cubes: I think the shifted pixels you're seeing are from the dilation step (and/or maybe the blendseams step). We see the same effect on the lightmaps of the imported cube and those don't show any artifacts, so I'm not entirely convinced that that's the (or an) issue.
This isn't the case, when using texel scaling in the lightmapper node the artifacts do go away, but when increasing the texel size for primitive meshes in the project settings and regenerating their uv2 the artifacts stay, despite being at a higher resolution. Does look like the issue is insufficient padding between islands. The normal EXRs reveal that the primitive cubes only have 1 pixel of padding between the islands: Compared to two pixels for imported cubes: I'm guessing when using texel_scale it does not change any padding, so when baking with a texel scale of 2, the primitive islands do have 2 pixels of padding, getting rid of the bleeding. I don't know why there is a pixel missing in one corner in each island, this could be giving that shifted pixel impression too once dilation has happened and filled that pixel in. I'm not entirely sure why this padding is so tight on both though. I'd expect the denoiser to cause leakage with islands this tightly packed too, which you can see in the leakage/padding example in #91601 (comment) |
For reference, UV2 on primitive meshes was added in #67975. |
maybe off by 1 error in some loop? |
The editor (current dev build v4.3.beta.custom_build [8e2141e] ) is freezing up for me when I try to bake after changing the lightmap padding on the primitive to anything other than 2 (i.e. 3 or 4). The freeze happens on determining optimal atlas size, there seems to be something funky going on here with the uv2 generation. |
Godot version
v4.2.stable.official [46dc277]
System information
Godot v4.2.stable - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Tue Nov 28 20:37:45 UTC 2023 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 SUPER (nvidia; 545.29.06) - AMD Ryzen 9 3950X 16-Core Processor (32 Threads)
Issue description
black rectangles (appeared in other places too):
texture bleeding?
without denoiser:
this one seems like it uses UV1 instead of UV2.
after deleting the corner prefab and creating a new instance this offset thing was fixed.
UV1:
UV2:
light penetration?
Steps to reproduce
don't know how.
might be related to 4.1 to 4.2 upgrade?
Minimal reproduction project
tried create a new project with the same wall/floor/ground meshes but it didn't reproduce it.
The text was updated successfully, but these errors were encountered: