guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Scene with two lightmapped prefabs - works fine in editor, second unlit in build #138

Open bfod opened 2 years ago

bfod commented 2 years ago

I have a scene that has two lightmapped prefabs loaded. On start one is enabled, the other is disabled.

At runtime, at some point they are switched - the second prefab is switched on and the first is switched off.

In editor playmode this works all totally fine. In build it works fine with one prefab, but not with two. With two prefabs, in build, the second one appears totally unlit (except by realtime lights).

No errors in the player log.

This is latest Bakery from Github, Unity 2021.3.4 and Windows.

guycalledfrank commented 2 years ago

Hi, did you check this? https://geom.io/bakery/wiki/index.php?title=Troubleshooting#Baked_prefabs_instantiated_at_runtime_in_a_build_have_no_lightmaps

bfod commented 2 years ago

Yeah but I don't think it can be either of those things: both prefabs use the same mesh and the same shaders, just different lightmaps, and the first one works fine, so I can't believe the shaders are being omitted or the mesh optimization is at fault.

If it's helpful I can construct a repro project.

guycalledfrank commented 2 years ago

Repro project would be definitely helpful!

bfod commented 2 years ago

I figured out what it is - if you turn a lightmapped prefab on in Awake(), using a script that has an execution order before the default time, then it fails in build. It works under all other conditions.

For now I'm just gonna adjust my execution order but I figured you should know.

On Wed, Jun 22, 2022 at 2:03 AM Mr F @.***> wrote:

Repro project would be definitely helpful!

— Reply to this email directly, view it on GitHub https://github.com/guycalledfrank/bakery-issues/issues/138#issuecomment-1162680576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3PSCQQUADYOEBATMYHGFDVQKUE3ANCNFSM5ZOD3UGA . You are receiving this because you authored the thread.Message ID: @.***>

blanxdev commented 2 years ago

I had I similar result when adding a baked prefab to a baked scene. when loading the scene together with the prefab, the scene was rendered black.

guycalledfrank commented 1 year ago

@bfod Interesting... so when you enable the prefab, the ftLightmapsStorage on it should instantly initialize and apply the lightmaps. Not sure why it doesn't happen.

@blanxdev do you have the same case? I.e. execution order and not just what I have at the Troubleshooting page?

bfod commented 1 year ago

Specifically, it turned out that making ftLightMapStorage execute earlier solved the problem.

On July 7, 2022 at 6:39:11 PM, Mr F @.***) wrote:

@bfod https://github.com/bfod Interesting... so when you enable the prefab, the ftLightmapsStorage on it should instantly initialize and apply the lightmaps. Not sure why it doesn't happen.

@blanxdev https://github.com/blanxdev do you have the same case? I.e. execution order and not just what I have at the Troubleshooting page?

— Reply to this email directly, view it on GitHub https://github.com/guycalledfrank/bakery-issues/issues/138#issuecomment-1178323677, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3PSCUAIJL6N2OGIZYJHRLVS5MA5ANCNFSM5ZOD3UGA . You are receiving this because you were mentioned.Message ID: @.***>