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.
655 stars 91 forks source link

LightMaps are Misplaced #37

Open sagarmicronixsystem opened 3 years ago

sagarmicronixsystem commented 3 years ago

In my project my lightmap are working fine if i am instantiating them as a prefab (Image1: Instantiating as a prefab) image

but when i am building the asset bundle of that prefab and try load that asset then the lightmaps are getting misplaced: (Image 2: Instantiate from asset bundle of above prefab) image

can anyone suggest me whats the issue (i am using unity 2020.3.4f1 URP)

Ayfel commented 3 years ago

Does your instantiating as prefab work when you make a build? It does sound like the shader stripping (look at ReadMe) or some setting in your project. Let me know.

sagarmicronixsystem commented 3 years ago

No i have check it they are not working in builds if i instantiate that prefab , they are just working in editor after baked prefablightmap i am building it for windows

Ayfel commented 3 years ago

Cool, so that means it is just your settings, once you fix those it will be fine. Check the readme for the stripping modes

sagarmicronixsystem commented 3 years ago

tried messing with lightmap modes to custom but not worked

Ayfel commented 3 years ago

Does you prefab still have the static flag on?

sagarmicronixsystem commented 3 years ago

after building lightmap should i remove all flags? i am just keeping batching static of

Ayfel commented 3 years ago

If you leave the batching static flag it will combine meshes and mess the UVs, that's the only one you should be careful with

sagarmicronixsystem commented 3 years ago

what should i do should i keep batching static flag on or off

Ayfel commented 3 years ago

You should turn it off so it doesn't combine meshes together. Let me know if that fixes it since it still might be something else

sagarmicronixsystem commented 3 years ago

i have tried in that way too nothing works

sagarmicronixsystem commented 3 years ago

Should i share my URP with you so that you can test it....

sagarmicronixsystem commented 3 years ago

its just a simple test project with some baked cubes from probuilder

sagarmicronixsystem commented 3 years ago

i have made a test on very small project the same project works in standard pipeline very well no issues in build but not working Properly in URP tried messing with all settings no luck

Ayfel commented 3 years ago

You need to bake (as in create actual meshes and not dynamic meshes, not bake as in lighting) your probuilder meshes or you will have issues in builds. It is a known issue with probuilder (maybe just in URP though).

Did you try including your prefabs inside your scene? In some cases this has shown if the issue persists.

Feel free to send me the test. I have done tests myself with URP and no problems so I would suspect is the probuilder assets

sagarmicronixsystem commented 3 years ago

okay i have created one new simple scene with one plane one cube and one point light using default unity objevcts it works well for them . my question is should my mesh have separate uv channel for lightmapping because unity generate lightmap uvs dont work properly with this script for the external objects as i think so..................

Ayfel commented 3 years ago

I use generated lightmap uvs from unity all the time, that makes no difference for the script or the lightmaps. What I understood was that you were using probuilder meshes which will have issues, but if you transform them down to regular meshes it should be ok

sagarmicronixsystem commented 3 years ago

i have exported that mesh and after that tried generate lightmaps uv but that case doesnt work for me.......

Ayfel commented 3 years ago

Can you share the mesh thats giving you issues?

sagarmicronixsystem commented 3 years ago

https://we.tl/t-sPjcixnOfA

there are 2 meshes i also provided texture just check once if they works fine for you

sagarmicronixsystem commented 3 years ago

this meshes aRE EXPORTED FROM PROBUILDER

meedo2009 commented 1 year ago

You need to bake (as in create actual meshes and not dynamic meshes, not bake as in lighting) your probuilder meshes or you will have issues in builds. It is a known issue with probuilder (maybe just in URP though).

Did you try including your prefabs inside your scene? In some cases this has shown if the issue persists.

Feel free to send me the test. I have done tests myself with URP and no problems so I would suspect is the probuilder assets

hey, how do i bake probuilder meshes, does that mean i have to not use probuilder at all?

Ayfel commented 1 year ago

You just need to use the "Export" to save the mesh/3d object in your project so its not a dynamic "probuilder" object and UVs are proper and good for this to work. Otherwise probuilder won't save properly to the prefabs you create.