lightmap-switching-tool icon indicating copy to clipboard operation
lightmap-switching-tool copied to clipboard

Support Asset bundle workflow

Open fcagnetta opened this issue 4 years ago • 5 comments

Hi and thanks for this tool :) I'm experiencing an issue with light probes. I follow all the instructions, BUT, I do not build the app with the scenes inside, I make asset bundles instead and download them via the internet through the app. So, in the asset bundle, I include the "master" scene only (so, not the "day" n "night" scenes). The lightmaps are correctly included, but the LightingData assets are not. I think here's the problem with the light probes. Do you think is there some way to link these assets in the master scene?

fcagnetta avatar Mar 17 '20 09:03 fcagnetta

Hi, the lightprobes are saved in the lightmap data component which is in the master scene so this means it can only access the lighting scenarios you have built before you publish your master scene.

One could turn the lighting data saved in the lightmap data component into scriptable objects so that you could save them as individual assets. Then when you add more lighting scenes you could also include the lighting data scriptable object in the asset bundle.

This is something I wanted to do but it would take some time that I cannot spend right now.

laurenth-personal avatar Mar 17 '20 10:03 laurenth-personal

Hi, the lightprobes are saved in the lightmap data component which is in the master scene so this means it can only access the lighting scenarios you have built before you publish your master scene.

So it should just work, because LevelLightmapData component is there, with its stuff inside?

One could turn the lighting data saved in the lightmap data component into scriptable objects so that you could save them as individual assets. Then when you add more lighting scenes you could also include the lighting data scriptable object in the asset bundle.

It's something that is out of my skills at the moment, but it's a good point.

This is something I wanted to do but it would take some time that I cannot spend right now.

I can understand, thank you for the work you've done so far

fcagnetta avatar Mar 17 '20 13:03 fcagnetta

Hi, the lightprobes are saved in the lightmap data component which is in the master scene so this means it can only access the lighting scenarios you have built before you publish your master scene.

So it should just work, because LevelLightmapData component is there, with its stuff inside?

The arrays of lightprobes are in the LevelLightmapData so the ones you have built and stored before saving the scene will be there.

laurenth-personal avatar Mar 17 '20 13:03 laurenth-personal

Hi, I was curious to see how long it would take to convert the data to scriptable objects so I did a quick version. You can check out this branch : https://github.com/laurenth-personal/lightmap-switching-tool/tree/2019.3-scriptable-object

So right now you have to create lighting scenario data assets by hand in the resources folder of the project : right click / create / lighting / lighting scenario data and reference them in the level lightmap data component so that when you press the store button the data goes to the scriptable object. Then you need to save so the assets get their changes saved. The logic that stored it in the scene previously is gone so if you don't reference a lighting scenario data asset nothing happens.

The LoadLightingScenario method is now asking for a scene name string and not an index which makes it possible to load something that has been built separately (the scene can be built with say 2 lighting scenarios and you can add a 3rd one later in theory).

Right now it's not possible to use a different lightmap resolution for the various lighting scenarios because I don't load lightmap scale and offset (it's probably doable but I haven't tried yet).

In order to make this work with asset bundles one would have to change the FillDictionnary method as this one only loads whatever is in the resources folder.

laurenth-personal avatar Mar 20 '20 07:03 laurenth-personal

I have made some improvements to the scriptable object branch as I think this is the right way forward. Storing the lighting data in an asset is nice as it doesn't dirty the scene, and it make it possible to use asset bundles. The master branch is now also using scriptable objects but doesn't support the rest of the workflow as it is not fully optimized yet.

laurenth-personal avatar Apr 11 '21 19:04 laurenth-personal