PrefabLightmapping icon indicating copy to clipboard operation
PrefabLightmapping copied to clipboard

LightMaps are Misplaced

Open sagarmicronixsystem opened this issue 3 years ago • 22 comments

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)

sagarmicronixsystem avatar Apr 30 '21 15:04 sagarmicronixsystem

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.

Ayfel avatar Apr 30 '21 15:04 Ayfel

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

sagarmicronixsystem avatar Apr 30 '21 16:04 sagarmicronixsystem

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

Ayfel avatar Apr 30 '21 16:04 Ayfel

tried messing with lightmap modes to custom but not worked

sagarmicronixsystem avatar Apr 30 '21 16:04 sagarmicronixsystem

Does you prefab still have the static flag on?

Ayfel avatar Apr 30 '21 17:04 Ayfel

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

sagarmicronixsystem avatar Apr 30 '21 17:04 sagarmicronixsystem

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

Ayfel avatar Apr 30 '21 17:04 Ayfel

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

sagarmicronixsystem avatar Apr 30 '21 18:04 sagarmicronixsystem

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

Ayfel avatar Apr 30 '21 18:04 Ayfel

i have tried in that way too nothing works

sagarmicronixsystem avatar Apr 30 '21 20:04 sagarmicronixsystem

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

sagarmicronixsystem avatar May 21 '21 09:05 sagarmicronixsystem

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

sagarmicronixsystem avatar May 21 '21 09:05 sagarmicronixsystem

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

sagarmicronixsystem avatar May 21 '21 09:05 sagarmicronixsystem

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

Ayfel avatar May 21 '21 14:05 Ayfel

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

sagarmicronixsystem avatar May 27 '21 14:05 sagarmicronixsystem

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

Ayfel avatar May 27 '21 17:05 Ayfel

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

sagarmicronixsystem avatar May 28 '21 14:05 sagarmicronixsystem

Can you share the mesh thats giving you issues?

Ayfel avatar May 28 '21 14:05 Ayfel

https://we.tl/t-sPjcixnOfA

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

sagarmicronixsystem avatar May 28 '21 15:05 sagarmicronixsystem

this meshes aRE EXPORTED FROM PROBUILDER

sagarmicronixsystem avatar May 28 '21 15:05 sagarmicronixsystem

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?

meedo2009 avatar Jun 12 '23 15:06 meedo2009

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.

Ayfel avatar Jun 12 '23 15:06 Ayfel