-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add optional UV2 logic for lightmapping to primitive shapes #67975
Add optional UV2 logic for lightmapping to primitive shapes #67975
Conversation
For what I can recall, emissive materials were working on baked lightmaps |
c4a4b16
to
672415b
Compare
In Godot 4, emissive materials require the mesh with the emissive material to have UV2, and have its GI mode set to Static. In Godot 3, meshes that don't have UV2 but had Use In Baked Light enabled could still contribute to lightmaps. |
Before this gets merged, had some more thoughts about improving the UV algorithm. Also on chat there was a suggestion to automatically assign the |
I wonder how XAtlas determines this. It uses a Lightmap Texel Size property that is defined in the 3D scene's import options: Since PrimitiveMesh doesn't have import options, we can add such a property to the PrimitiveMesh resource instead of making it an import option. Adjusting this property will cause the lightmap size hint to be updated. |
@Calinou hmm, I wonder if it doesn't make more sense to make it a project setting, else we'll start getting questions of people wanting it to calculate backwards when they update the lightmap size and we'll need to do some sort of aspect ratio fixation. |
672415b
to
3f2563f
Compare
Ok adjusted most UV2 calculations so they are based on actual sizes of the objects, just need to do Also still need to add @Calinou the texelsize mentioned, if it's 0.2 does that mean that 1 pixel is 0.2 x 0.2 sized? So a square meter would have a 5x5 pixel grid for lighting data? |
The project setting approach sounds fine to me. Just make sure the default matches what imported meshes use by default.
It means each texel square is 0.2×0.2 units. Larger values result in less detailed lightmapping, as the object will have fewer texels on the lightmap texture. For reference, the default was increased from 0.1 to 0.2 in #58071 to speed up baking significantly. When baking indirect lighting only (which is the default setup in Light3D), it ends up looking very similar in practice. |
3f2563f
to
fd0fe85
Compare
I've changed this back to draft as I put the final things to it. It's been a bit of puzzling. I'm changing the UV2 calculation to be based on actual dimensions of the object and to update the lightmap size hint based on a new project setting. So far I've adjusted:
|
fd0fe85
to
f7ca122
Compare
f7ca122
to
9a4e968
Compare
Finished prism and torus, I don't think the meshes for particles/trails require the UV2 treatment so I've left those to the default logic. Prism and Box meshes could use some improvement to better pack the faces and prioritize sizes for smaller textures but I'll leave that for someone with more time on their hands :P |
8dcf0bc
to
69e6add
Compare
69e6add
to
6c19950
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.
Implementation looks fine to me, we need @reduz to approve the API additions though
6c19950
to
7658dc6
Compare
Android build failure seems to be an issue with the CI, not the code, @akien-mga ? |
Thanks! |
This PR introduces optionally adding UV2 texture coordinates to primitive shapes including support for padding along the seams of the mesh. It will also set the
lightmap size hint
based on a texel size that can be configured in project settings:The default values of this is
0.2
.The Primitive Meshes related to particles have not been changed.
This PR supersedes #49932