lightmap transitions?

I am trying to create two lightmap sets for two times of day in the scene. The plan is to be able to transition from one to another. Using new lightmapping techniques does not seem to support that. I tried to write a shader to blend second lightmap previously generated but I realized that I do not have access to the uv set generated via Beast tool, I tried using secondary uv set but it is not the one generated while baking lightmap on an object. Is there a way within Unity I can achieve what I want? Only solution I currently see is to use external package to bake lightmaps and generate second UV set, then import them in Unity and write a shader that blends the two textures. I am hoping though that there is a way within Unity to do it. Any ideas? Thanks!

I've modified the mesh.uv2 before to access the beast generated light map set. Can you quick check to see if that's what you want?

I've used it to apply a generated lightmap to a new set of meshes- because we wanted to share a lightmap with a cloned world.


Make sure "Generate UV coordinates" is checked in your mesh importer? Probably not the problem you had though...

Good luck- I do remember it was a bit finicky, but I think that was me just not understanding what was happening under the hood- unity doesn't give you too many hints.

        MeshFilter meshFilter = r.GetComponent(typeof(MeshFilter)) as MeshFilter;
        Mesh mesh = meshFilter.mesh;
        Vector2[] uvs = mesh.uv2;
        int uvsLength = uvs.Length;
        Vector4 lightmapTilingOffset = r.lightmapTilingOffset;
        Vector2 scale = new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
        Vector2 offset = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);

        for (int i=0; i < uvsLength; i++) {
            uvs <em>= offset + new Vector2(scale.x * uvs_.x, scale.y * uvs*.y);*_</em>
 <em>_*mesh.uv2 = uvs;*_</em>