I am currently trying to achieve the following:
Build the game with a Lightmap that has a rather small resolution of 256x256 or similar.
Once the player loads the game in the Browser (Unity Web) I want to download the better Lightmap (resolution of 1024x1024 or higher) via an AssetBundle and apply it to the scene, so the user can start playing with the “bad” Lightmap, and it will be upgraded/switched during playtime.
I already skimmed a lot of forum posts, especially:
So far I already got everything working from creating the different Lightmaps, uploading them as an AssetBundle, downloading it etc. but once I switch the Lightmap the shadows appear at different places, I am assuming this is because the resolution is different.
This happens no matter if I use Lightmaps from the Assetbundle that are downloaded during runtime or Lightmaps that are stored in the Assets Folder.
I am also using the Alternative Lights Manager for switching Lightmaps from the plugin mentioned in the Post above.
For reference
This is what the lightmap should look like:
I am currently thinking it has something to do with the LightingDataAsset, but I am not sure.
I am only using a single Directional Light that is set to Baked and Hard Shadows.
So, there are 2 settings to keep in mind here:
Max Lightmap Size - Controls to the maximum size of the lightmap texture in pixels. This is what you are calling “lightmap resolution”.
Lightmap Resolution - Controls texel density, ie. how many texels in the lightmap each unit in worldspace will translate to.
Say you have a scene that uses 2 512x512 lightmaps, with Max Lightmap Size set to 512. If you bump the Max Lightmap Size to 1024, the size of each individual renderer in the lightmap won’t change, but you’ll be able to fit more into a single single lightmap, so you’ll end up with 1 single 1024x1024 lightmap instead of 2 lightmaps with 512x512 size. The visual fidelity won’t change at all though.
If you instead halved the Lightmap Resolution, each renderer would take up half the amount of space, so you’d be able to fit the entire thing in a single 512x512 lightmap, at the cost of some visual fidelity. (this is a bit of simplification, but gets the point across)
So, both of these settings effect how renderers are packed/placed into the lightmap. If you compare the layout of your 2 sets of lightmaps, you should see the difference. You can use the lightmap preview window (Window > Rendering > Lighting > Baked Lightmaps > Open Preview) to compare them.
The packing of renderers in the lightmap isn’t something we currently provide a way for the user to control, but we’d like to in the future, in order to support specialized use cases such as your own.
If you are lucky, you might be able to get the same lightmap layout at different resolutions by doubling both the settings I mentioned, but I don’t believe we make any guarantees about the layout in general. I’m not sure if there are community-made solutions for this (you could for example manually move around portions of the lightmap texture post-bake, or you could bake only at the highest resolution, and then manually resize the lightmap to a smaller size without changing the layout to get the “cheap” version), but I’m afraid I can’t provide with you with a first-party solution.