guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Light map groups don't work correctly for a group of terrains #119

Closed pedropla closed 2 years ago

pedropla commented 2 years ago

I have a group of 4 terrain tiles and when I put them in a Lightmap Group the generated lightmap doesn't look correct and doesn't work properly. The lightmaps seem cut and there are large portions missing. This is the generated lightmap: image

guycalledfrank commented 2 years ago

Hi. What is the packing mode on the lightmap group ("pack atlas" should be OK)? Are you using xatlas as the atlas packer? Are you using Terrain Optimization? Can you send me any small test project?

pedropla commented 2 years ago

These are my Bakery settings. I'll try to make a repo project that doesn't depend on any assets but I'm not sure when I'll be able to get around to that.

image image

guycalledfrank commented 2 years ago

For the repro I basically only need a scene containing Terrain objects with similar size/placement/lightmap groups. I don't need any other objects, lights, even heightmaps to test it.

pedropla commented 2 years ago

I've messaged you through the Unity interface with repro. If you prefer it sent another way just let me know.

guycalledfrank commented 2 years ago

The joy of having multiple versions of everything...

So when terrain optimization is off, the terrains are converted into temporary meshes that can be exported as regular geometry. These meshes were also split into 256x256 chunks to prevent indices from going over 64k, as previously Unity only supported 16-bit indices. These smaller chunks were then packed by the atlaser, which jumbled them around. So any terrain with a >256 heightmap, packed inside a manually created group, couldn't map the resulting atlas.

I've pushed a fix (https://github.com/guycalledfrank/bakery-csharp/commit/d727702fb0a4ce5e8b9c20921f135623be8e8069) which just removes the splitting on Unity versions >=2017.3.

It works now when terrain optimization is disabled. When it's enabled. the logic is a bit trickier. Given it's also a no-go for RTX hardware anyway, currently I just added a warning window asking to disable the optimization when groups are used.

pedropla commented 2 years ago

Thanks. It works now! Do you think it's worth maintaining the option for terrain optimization since RTX is used in all modern Nvidia graphics cards?

guycalledfrank commented 2 years ago

Maybe. Its main purpose is reducing memory usage for high-resolution terrains, by tracing them directly as heightmaps instead of triangles. It can still do this, but it's slower than triangles with RTX, or even sometimes without the RTX.