The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+3 votes

My game uses 3D level geometry imported from COLLADA files exported from Blender.
When I manually Unwrap UV2 for Lightmaps in Godot it works only in the engine viewports - as soon as I run the game, the .dae file is being re-imported, the UV2 mapping is gone and the lightmaps don't work.

If I discard instancing of my 3D scene - it will work, but I can't easily update my geometry from Blender export.

I'd like to be able to automatically unwrap UV2 fro lightmaps as soon as the COLLADA file is being imported so that I can have it instanced and use lightmaps at the same time.

How can I do this?

in Engine by (217 points)
edited by

1 Answer

+2 votes

It's been a long time since you posted this question, but i'm running into this problem. My attempt to solve it is using code (which can be runned as tool script if you wish) which will unwrap UV2.

extends MeshInstance

export(float) var lightmap_texel_size = 0.4

func process_uv2():
    var old_mesh = mesh as Mesh
    mesh =
    for surface_id in range(old_mesh.get_surface_count()):
        var old_mat = old_mesh.surface_get_material(surface_id)
        mesh.surface_set_material(surface_id, old_mat)

    mesh.lightmap_unwrap(global_transform, lightmap_texel_size)
    use_in_baked_light = true

func _ready():

I won't consider it to be an answer, but it can be useful for others.

by (22 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.