Ayfel / PrefabLightmapping

Script for saving lightmapping data to prefabs. Used through the Assets tab in Unity. Place your prefbas in the scene with this script at the root. Set up your lighting and in the editor go to Assets->Bake Prefab Lightmaps. After is processed you can now spawn your prefabs in different scenes and they will use the lightmapping from the original scene.
624 stars 89 forks source link

Issue on iOS build vs Editor in URP 7.2.1 #9

Closed jacksandham-va closed 3 years ago

jacksandham-va commented 4 years ago

Come across an issue where we're trying to setup a lighting scene for an object at scale 100 in editor and the bake looks different in editor vs on iOS. This happens even when testing within the same scene. The lightmap scale looks incorrect on iOS.

Setup:

Any ideas?

Ayfel commented 4 years ago

Is it just the scale that causes the issue?, if you set a different scale things work well?

Just to make sure, the lightmap is being applied in the build just not properly? (as in the lightmaps shaders are not stripped in the build , look in the readme).

Also can you reproduce it with a different object? let's say a cube at scale 100 as well?

jacksandham-va commented 4 years ago

Thanks for your quick reply.

  1. Yes at scale 1 object is lit correctly (after changing lights to fit scale 1)

  2. Yes checked your readme and have tried various Custom settings for lightmap shader stripping. I can see the lightmap on the object (it just doesn't look right).

  3. I've tried a simpler object and can reproduce as well at scale 100 with slightly different behaviour. Lighting looks different than in editor still but looks almost just like ambient lighting. Whereas my other object you could see the incorrect mapping.

I'm trying a few different things with other light types and scales.

Ayfel commented 4 years ago

Ok thanks for the info. One last question, this only happens on a build correct? Meaning that in the editor everything looks correct in play mode?

It would be interesting if you could share some pics or a repo project for me to look at too.

Also I wonder if this happens regardless if you try simply lightmapping normally with Unity...

jacksandham-va commented 4 years ago

Yes only in build, in play mode it looks good regardless of scale and even in another scene. Actually even at scale one with the other object it still doesn't look the same (think it was false hope) on iOS.

So I think it's an iOS build issue. I've just generated lighting normally with Unity and that's fine. Strange!

Ayfel commented 4 years ago

mmm, this definitely sounds like an IOS build issue, try doing uncompressed lightmaps, but it is very strange since you mention that you baked normally with unity and it worked. Let me know if you can provide a repo for me to check

jacksandham-va commented 4 years ago

Yes these are uncompressed. I think we didn't have this issue in 2019.2 and LWRP 6.9.2 but I will confirm as well. I will try sort a demo scene for tomorrow.

jacksandham-va commented 4 years ago

Another note, I can make the editor and iOS behave the same by applying a scale to the lightmap scale parameter. Not sure why...

jacksandham-va commented 4 years ago

I've now duplicated behaviour in editor by having a duplicate of the model in the scene. I'm going to try replicate this in the sample scene.

jacksandham-va commented 4 years ago

Okay I've found a workaround setup. For the baking side we had to have the original FBX for the model in the scene we're baking, marked as static but without the script. We were original trying to bake onto a prefab that had that fbx in it. Secondly we had to include the scene that it was baked in, in the build settings. Not sure if this was required before as we didn't do it but it seems obvious given it has the lighting data in it.

Ayfel commented 4 years ago

I am glad you found a workaround. I would still like to understand and reproduce the issue in case there is something off. Did you figure out if this was something only happening in the newest 2019.3?

Including the scene in the build would make those stripping shaders to always be included, that's what it sounds like at least.

jacksandham-va commented 4 years ago

Yes I agree, I'll working on getting two sample projects for this in both Unity Versions.

Ayfel commented 4 years ago

Awesome, thank you

Ayfel commented 3 years ago

I have now tested this on URP in 2020.3.5f1 at different scales and in different devices and I cannot seem to reproduce, also in HDRP. Closing for now