PrefabLightmapping icon indicating copy to clipboard operation
PrefabLightmapping copied to clipboard

Baked shadows not working properly

Open viknesh2020 opened this issue 4 years ago • 17 comments

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

viknesh2020 avatar Nov 30 '20 11:11 viknesh2020

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?

Ayfel avatar Nov 30 '20 13:11 Ayfel

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

viknesh2020 avatar Jan 21 '21 09:01 viknesh2020

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)

Ayfel avatar Jan 21 '21 14:01 Ayfel

  • 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.

viknesh2020 avatar Jan 22 '21 08:01 viknesh2020

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.

Ayfel avatar Jan 22 '21 13:01 Ayfel

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?

viknesh2020 avatar Jan 22 '21 13:01 viknesh2020

Sure no problem

Ayfel avatar Jan 22 '21 13:01 Ayfel

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

viknesh2020 avatar Jan 22 '21 14:01 viknesh2020

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

Ayfel avatar Jan 22 '21 14:01 Ayfel

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

Ayfel avatar Jan 22 '21 15:01 Ayfel

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 :(

viknesh2020 avatar Jan 25 '21 11:01 viknesh2020

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

Ayfel avatar Jan 27 '21 17:01 Ayfel

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 :)

viknesh2020 avatar Jan 28 '21 03:01 viknesh2020

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.

viknesh2020 avatar Jan 29 '21 10:01 viknesh2020

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...

Ayfel avatar Feb 12 '21 23:02 Ayfel

I have the feeling its related to URP , looks at this other issue https://github.com/Ayfel/PrefabLightmapping/issues/9

Ayfel avatar Feb 13 '21 00:02 Ayfel

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.

Ayfel avatar Feb 13 '21 01:02 Ayfel