Unwrapping.GenerateSecondaryUVSet() will create a secondary UV2 set.
But how to create an additionally UV4 set. And then copy the existing Lightmap UV2 set correctly to UV4? Does anyone how that can be done?
Another problem seems clearing bake will flush per-renderer unity_lightmapST variable, that changes the lightmapScaleOffset and lightmapIndex property.
In the end I want to have a resistant UVset that contains a single AO-Map per renderer, can be rendered through a custom shader.
Where are you creating your AO? In your 3D modelling package? Are you packing it into an atlas that matches what Unity generated during the bake and placed into lightmapScaleOffset and lightmapIndex?
I’m trying to understand:
a. why do you even need those properties
b. why are you clearing the bake
We must use project based day-night cycle on a large outdoor environment. (Keep this in mind)
Real-time global illumination is NOT possible in this case.
We bake AO-Maps by UNITY onto each Scene part with RelatimeGlobalIllumnation = Off.
Buildings of a scene contain Interiors as well. These are loaded separately on player position.
After the AO Map baking processed by UNITY, we optimize the AO maps by a software process that results in a superior visual result. Then want to move the complete Unity based (untouched) UV2 to any independent and resistant UV_X Set.
An independent UV set is required, because now we let UNITY bake the environment lightning Sky again (without AO) to have the ability to change the Environment Lightning (probe) during the day to night cycle.
In case of the whole production process, it’s much more efficient, convenient and cost-efficient to bake in Unity with a software baking optimization, than baking external.
But when copying UV2 to UV4 and using a custom shader it works well as long unity_LightmapST.xy + unity_LightmapST.zw are not flushed, by any rebake.