Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/z3y/xatlaslightmap
Better lightmap packing for Unity
https://github.com/z3y/xatlaslightmap
bakery lightmap packing unity xatlas
Last synced: 9 days ago
JSON representation
Better lightmap packing for Unity
- Host: GitHub
- URL: https://github.com/z3y/xatlaslightmap
- Owner: z3y
- License: mit
- Created: 2023-03-13T23:25:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-15T17:07:32.000Z (3 months ago)
- Last Synced: 2024-08-15T19:19:17.251Z (3 months ago)
- Topics: bakery, lightmap, packing, unity, xatlas
- Language: C++
- Homepage:
- Size: 393 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XatlasLightmap
A tool for the most efficient lightmap packing in Unity.
## How it works
It generates unique uv2 per mesh, instead of using lightmap UV offsets, which when combined with static batching doesn't create any extra cost. Additional vertex streams are used to set uv2 in editor, which requires modifications to bakery scripts. Lightmap Scale is also calculated differently which allows it to have perfectly uniform texel density when lightmap scale is set to 1.## How to use
- Add package with git `https://github.com/z3y/XatlasLightmap.git`
- Patch Bakery `Tools > XatlasLightmap > PatchBakery` (only once)
- Add a `XatlasLightmapPacker` script on a GameObject
- Select a BakeryLightmapGroup asset with Packing Mode set to Original UV
- Generate Lightmap UVs on the model importer or create custom UV2
- Enable mesh Read/Write on the model importer
- Pack[Share your lightmaps](https://github.com/z3y/XatlasLightmap/issues/6)
## Limitations
- Nested lightmap groups arent supported yet
- Doesn't work with GPU instancing, since every mesh ends up being unique. Only use with static batching.
- Model reimports will break the mesh until packed again.
- Since the packing is so efficient and the padding gets applied correctly most shaders will have slight bleeding at 2px, it is recommended to use a centroid interpolator for the lightmap UV.
- Using bicubic sampling requires more padding
- Lightmaps might fail to bake properly first time
- Only works with Bakery
- Sometimes on build it can fail to get UV2 because Read/Write is disabled, even tho its not needed for an editor script. This also doesn't affect the build size. The original mesh is never referenced, only the combined static mesh gets included.## Examples
Sponza:
![Screenshot 2023-03-18 164316](https://user-images.githubusercontent.com/33181641/227739457-d5bd302d-ba14-4e1f-a745-da5942e1215b.png)
Checker preview:
![image](https://github.com/z3y/XatlasLightmap/assets/33181641/ab5af17a-ef49-442e-96cc-d0cd0295acdd)
Sponza 2:
![image](https://github.com/z3y/XatlasLightmap/assets/33181641/6b791015-51c1-4d12-b0bd-16452dc802bf)