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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Baked shadows not working properly

viknesh2020 opened this issue · comments

Is there any way to make this shader work for baked lightmaps? I am not getting shadows at all If I bake lights.

commented

Can you share your light settings? Baked shadows is one of the main applications of this, so maybe your light settings are not in the right setup. Do you get indirect lighting?

Sorry my bad. The question was wrong actually. It works for baked lightmaps. The issue is, there are patches over the object everytime I bake lightmap. In the editor, it looks fine. But when I take a build for my iPad, there are irregular shadows and black patches all over the object. I checked the closed issues and found out that disabling static flag will solve this issue. However, still this issue exists. Screenshots are below for your reference.

IMG_0020
IMG_0019

commented

Things to check:

-check shader stripping the graphics settings (see the readme of this repo), this affects builds
-try with non compressed light maps
-make sure in the editor that instantiating these objects work fine
-If nothing works I would recommend going as far as creating a scene with instantiated objecs just for testing in device to eliminate the possibility that there is something else in your project affecting the lighting (I see you are in AR so doing a non AR scene with the prefabs simply to check)

  • Tried the shader stripping in both custom and automatic. No luck !
  • Tried uncompressed and compressed lightmaps. Both didn't work
  • Created a new scene to instantiate the same prefab in the editor. Worked fine.
  • Tried the same scene in the build, but didn't work. Screenshots below,

Build
Editor

First image is taken from my iPad. I cleared the bake data and reset my lighting tab settings and tried this. Still didn't work.

commented

Thanks for doing those. What Unity version are you at? Can you send me a minimal project to check? Just that simple scene and prefab and I can check the issue.

Thanks for doing those. What Unity version are you at? Can you send me a minimal project to check? Just that simple scene and prefab and I can check the issue.

Sure. I will share you the link. I guess I have to share you the entire project, so that you can have a look at the graphics and lighting settings. Is that ok?

commented

Sure no problem

Here is the link to the entire project. This is a temporary link, so download it as soon as possible. I am using Unity 2019.4.10f1.
Xcode version 12.3. If you need any other information, let me know. Thank you for your help in this.

https://we.tl/t-dUQVWZnhf5

commented

Ok I got it, but what scene am I checking? There is one called PrefabTest but it doesn't instantiate anything

commented

Also
I noticed that your chair and table prefabs are disconnected (the one in the scene you had and the one in your Assets have different lighting data so that might be messing with it). I recommend substituting the one in Assets with the one in your scene that works. Drag and drop from the scene into the assets prefab and substitute the prefab, if you are instantiating the prefab in assets that had the wrong data

Sorry. The scene that we have to check is 'FurnitureAR'. Also, the scene 'PrefabTest' is having a button at the left corner to instantiate the prefab.

I checked the prefabs again. It was rightly pointing at the lightmap data. So, to double check this, i did the following.

  • Cleared the baked data of the scene 'FurnitureAR'
  • Clicked on the Assets>>Bake Prefab Lightmaps.
  • After baking is complete, got the new Baked lighting data and automatically assigned them to the prefab.
  • Created a new original prefab by dragging and dropping the existing prefab in the scene hierarchy to the assets folder. Assigned those new prefabs to the instantiate script.
  • Built and checked. No luck :(
commented

I am on a trip right now, but I will check when I get back to my pc. I might need to build to IOS to confirm, but I will get back to you if you haven't fixed it by then

I am on a trip right now, but I will check when I get back to my pc. I might need to build to IOS to confirm, but I will get back to you if you haven't fixed it by then

Sure. Thank you so much :)

Update: Tried with a different model, to check if the issue is with uv of the model. Still having issue with the new model. Created an empty scene, didn't bake light for the new scene and used the existing prefab. Issue still exists.

commented

Ok so I have reproduced this issue succesfully in Android. Now the funny part, if I have those two models in the scene already then there is no issue and lighting works properly, also with any new models that I place after
I wonder if there is something funny in those URP shaders...

commented

I have the feeling its related to URP , looks at this other issue #9

commented

A very simple workaround seems to be to include those objects in your scene (enabled) really far away or super small. That solves it. Not a permanent solution but that will make it work for now. Still trying to figure it out.