Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Mesh Generating Realtime Light map, but not Baked Lightmap

Discussion in 'Global Illumination' started by Doddler, Oct 17, 2019.

  1. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    252
    I'm having a lot of trouble getting baked lighting to work in my scene, and I can't for the life of me figure out why. The scene is set up as such:

    - Point light which is static, and set to bake mode.
    - Static game object with a mesh which has had a secondary UV set generated using Unwrapping.GenerateSecondaryUVSet. Mesh shows as having both uv and uv2.
    - Contribute global and receive global: lightmaps set on the mesh renderer. Lightmapping scale is 1, parameters is default medium.
    - Shader is just standard shader with an albedo texture, nothing else.
    - Baked global set in the lighting panel.

    No matter what I do though, I can't get it to bake. The object does list a baked lightmap, but the lightmap is empty. The object is properly lit when baked global is disabled. Importantly, when I enable Realtime Global, it DOES generate a proper realtime lightmap, but not a baked lightmap.



    To test further, I created a cube primitive, and it is properly generating the baked lightmap for that object, and that object alone. I copied the mesh renderer properties over to my mesh, but no luck. Attached is a screenshot of the realtime lightmap generated, as well as the baked light map for the same screen. It does show a baked lightmap for the object in the inspector, but it only shows our cube on it. If the cube is not in the scene,

     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    692
    There might be something off with your scene or mesh setup. Have you tried creating a new project using a 3D with extras template, import your object, and see if it gets properly lit there?
     
  3. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    252
    Thanks for the reply, I think I figured it out, I was re-building secondary UVs on demand, but it turns out that you need to go through additional hoops if you modify a mesh in such a fashion. While I was re-assigning the updated mesh to the mesh filter, I needed to use Mesh.UploadMeshData() to be able to get it to recognize the newly generated UVs. I'm unsure why this only affected the progressive lightmapper and not the old one, but that solved the issue for me.
     
    kristijonas_unity likes this.
unityunity