guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Bakery rendered Light Probes in wrong positions #59

Open Zurigan opened 3 years ago

Zurigan commented 3 years ago

This happens in Legacy and L1 mode.

This is the scene after a Progressive 'Generate Lighting':

image

And this is after Bakery renders light probes:

image

Progressive matches where all the light probes are, for all groups in-scene. Bakery appears to be keeping some of the light probe positions and moving/deleting/creating others. Or maybe it's loading light probe positions from a cached file somewhere?

guycalledfrank commented 3 years ago

Are your Light Probe Groups in some deep rotated/scaled hierarchy?

Zurigan commented 3 years ago

Kinda ... the main group is 3 layers deep but unscaled/rotated, every tree also has a group that's the same depth, only the object they're on is scaled/rotated.

If I disable all the trees and move the main light probe group to the hierarchy root I get the same issue so, seems like in this case at least, it's not related to scale/rotation/nesting.

Zurigan commented 3 years ago

... Think this is some sort of caching issue. I tried deleting the light probe groups from the scene and re-running Progressive/Bakery. Progressive works as expected, Bakery rendered light probes look like the broken screenshot above. Somehow Bakery is ignoring what's actually in the scene.

After hitting 'Render Light Probes' the temp scene opens and I do see all the light probes in black, in their expected places ... then when switching back to the scene we're rendering probes for they're all created in the wrong places.

Restarting Unity did nothing, neither did deleting the frender temp folder or deleting/rebuilding Library or deleting Baker/_tempScene/LightingData.

guycalledfrank commented 3 years ago

Not sure, never happened on my scenes. Something weird about the scene? Can you send me this scene (no models needed, just the probe objects).

Zurigan commented 3 years ago

OK, some progress - If I copy the entire scene contents into a new scene Bakery light probe rendering will start working properly, even after en/disabling probe groups and re-running. So ... there's something in the Unity scene file that's tripping Bakery up.

I figured I'd try to work out what was different about the scene files and noticed the original was several times larger on disk. Still picking through why but it looks like part of the issue is that Bakery is repeat-saving lights hundreds of times over. Will log that as a separate issue. Scene files attached here, v2 is the new one that's smaller/still works with Bakery Light Probe rendering.

Scene Files.zip

Zurigan commented 3 years ago

Ok, the attached is the broken scene stripped down to just a plane, light, light probe group. Trying to render probes on this comes up with this error when returning from the tmp scene (where I can see all the expected probes):

image

stripped scene.zip

Zurigan commented 3 years ago

Ugh, toggling the 'Baked Global Illumination' checkbox in the Unity Scene Lighting settings seems to fix Bakery somehow.

Doesn't matter if you toggle it on or off, or on then off ... just toggling it one or more times fixes things. Also doesn't matter what state you leave it in, once Bakery starts working to render probes again it will keep working, for a while at least.

This is an especially vexing bug as it's possible you wouldn't notice for some time that Bakery had silently stopped rendering altered light probe groups.

Edit - this is the git diff on Lighting Settings after toggling 'Baked Global Illumination' any number of times on/off, on the lighting settings file:

-  m_GIWorkflowMode: 0
+  m_GIWorkflowMode: 1
guycalledfrank commented 3 years ago

Unpredictable bugs like this is one of the main reasons I implemented Volumes, as they don't depend on lighting data assets, light probe groups, GI workflow modes, etc, etc... lots of factors I have no control over, that have no documentation, no API and can change in future versions without warning. Unity's lighting system is a mess and it's better to stay away from it.

In this case seems like enabling Occlusion Probes will make it generate the probes fully, and the probes are correctly positioned after it.

image

Zurigan commented 3 years ago

Toggling Occlusion probes makes it work ... but also generates more files I don't want/need. Toggling occlusion probes off brings back the issue. So ... the best solution for this is still to toggle the Unity Lighting settings 'Baked Global Lighting'.

What I don't understand is why doing this persists the m_GIWorkflowMode change. I can see in the Bakery code that that property is getting set to the same value (ftLightmaps.cs Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;). With a breakpoint on that line it looks like it flips back and forth as Bakery renders probes/reloads scenes ... is Bakery caching the original value (0) of this property somewhere and restoring it? IS there Bakery code anywhere that sets it to 0?

FWIW Volumes are really clever but after playing around with them I think won't work for me. I'm planning to target mobile and, in order to get ok looking results, the generated files had to be really big.

guycalledfrank commented 3 years ago

Hmmm no, giWorkflowMode is never cached. The only time it's accessed is the one you found (setting it to OnDemand to prevent Unity from doing stuff in background).

Zurigan commented 3 years ago

Hrm, well, IDK what to suggest here ... does sound like it's a Unity issue BUT the result of this is that Unity light probe rendering works, Bakery's sometimes, for no discernible reason, doesn't.

Also irritating that it looks like giWorkflowMode is obsolete, doesn't actually get used by Unity to control auto-rendering of GI (right?).

I guess you could log a bug with Unity with the example scene I attached ... but they could turn around and say 'our lighting doesn't use that obsolete field, this isn't a Unity issue'. Tricky!