guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Bakery Volume occlusion issues in URP #49

Closed fender closed 3 months ago

fender commented 3 years ago

I'm having an issue where my dynamic player object is receiving light from a Bakery Volume (successfully) but it is receiving the light through a solid wall. Is there something I set up incorrectly?

unknown

In this screenshot you can see:

  1. The baked light in the room
  2. The outlines of the bakery volume that includes the player
  3. The player that is receiving light from the bakery volume
guycalledfrank commented 3 years ago

Is it only near the wall? If not, are you sure that the volume is correctly applied? Maybe the trigger didn't work? You can check it by disabling other volumes and making this one global.

fender commented 3 years ago

@guycalledfrank Thanks, that helped me track down the core issue. I need a volume to only be affected by certain lights. Is this possible?

Reasoning:

The issue in my screenshot above is because when I baked volumes, it was done with the lights on in the room the player is standing. I suppose I could go through manually and bake each volume 1 by 1 with only the correct lights on but thats going to be very tedious for larger maps (I have another one with 20 rooms).

guycalledfrank commented 3 years ago

Ah, I see. I can add the Bitmask property (the same as on the lights & LMGroups) to volumes, will it help?

fender commented 3 years ago

@guycalledfrank Would that mean only lights with the same Bitmask would match? I think that does help, although it means each of my rooms would need to be on their own bitmask too? At the moment I was just using 0 for everything.

fender commented 3 years ago

@guycalledfrank Alternatively, could we assign a lightmap group to a bakery volume? Bitmask is fine too I suppose.

guycalledfrank commented 3 years ago

Technically making volumes support groups will mean they render as separate "groups". Currently ALL volumes in the scene form one group internally.

fender commented 3 years ago

@guycalledfrank Ah, I see, OK. Bitmask is fine then! Let me know when I can help test it. 👍

fender commented 3 years ago

@guycalledfrank Hey - happy new year 👍 Do you have an ETA of when this might land?

guycalledfrank commented 3 years ago

Happy new year! Will implement it this month.

fender commented 3 years ago

Happy new year! Will implement it this month.

Hey @guycalledfrank did you manage to get to this one in the end?

guycalledfrank commented 2 years ago

No :( Every time I started working on it (and I did), I realized it's much more complicated than I anticipated. A lot of stuff to redesign. Currently you can bake volumes/rooms one by one, manually disabling certain lights between bakes and unchecking "Enable baking" from previous volumes, so they're not overwritten. You can also use Sectors to bake each room separately without rebaking or breaking other rooms: https://geom.io/bakery/wiki/index.php?title=Partial_scene_baking

fender commented 2 years ago

No :( Every time I started working on it (and I did), I realized it's much more complicated than I anticipated. A lot of stuff to redesign. Currently you can bake volumes/rooms one by one, manually disabling certain lights between bakes and unchecking "Enable baking" from previous volumes, so they're not overwritten. You can also use Sectors to bake each room separately without rebaking or breaking other rooms: https://geom.io/bakery/wiki/index.php?title=Partial_scene_baking

So you're suggesting to bake each room light and volume together, one by one, for each room right? That would setup the volumes and I would then disable Enable baking on them to protect their data.

Once the volumes are setup, I can then bake all the lights on and all the lights off so that I have a lightmap texture for each room (due to the Lightmap Groups) which I can toggle at runtime.

If you think that will work, I'll write a script to automate the process for me. That should be somewhat trivial, right? I could share the script back with you if you wanted to share it too.

guycalledfrank commented 2 years ago

That should work.

fender commented 2 years ago

That should work.

@guycalledfrank Just putting this together now. Any idea how to get Bakery to use the scene settings when baking from a script? When I press the Render button manually it (obviously) uses all the settings in that window but from the script it isn't.

    [MenuItem("Tools/GHO/Bake Lightmaps (ON)")]
    static void BakeRoomLightmapsOn() {
        BakeRoomVolumesProgressFunc = BakeRoomLightmapsOnInternal();
        EditorApplication.update += BakeRoomLightmapsOnUpdate;
    }

    static void BakeRoomLightmapsOnUpdate() {
        if (BakeRoomVolumesProgressFunc.MoveNext()) return;
        EditorApplication.update -= BakeRoomLightmapsOnUpdate;
    }

    static IEnumerator BakeRoomLightmapsOnInternal() {
        var bakery = ftRenderLightmap.instance != null ? ftRenderLightmap.instance : new ftRenderLightmap();
        bakery.LoadRenderSettings();
        bakery.RenderButton(false);

        while (ftRenderLightmap.bakeInProgress) yield return null;
        EditorSceneManager.MarkAllScenesDirty();
        EditorSceneManager.SaveOpenScenes();
        yield return null;

        Debug.Log("Baking of lightmaps (ON) completed");
    }
guycalledfrank commented 2 years ago

Get current settings:

ftLightmapsStorage storage = ftRenderLightmap.FindRenderSettingsStorage();

Change them, e.g.

storage.renderSettingsBounces = 2;

You can see the full list of setting variables in ftLightmapsStorage.cs, their names are descriptive:

image

Then call

bakery.LoadRenderSettings();

So it reloads settings and gets your changes.