From 31dacce6b2a96a48045d9eb05cbc65906b7a76f9 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 8 Oct 2017 22:03:43 -0400 Subject: [PATCH 1/3] Fix hidden UVs not being lightmapped --- korman/exporter/etlight.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/korman/exporter/etlight.py b/korman/exporter/etlight.py index d55a8ae..8959f02 100644 --- a/korman/exporter/etlight.py +++ b/korman/exporter/etlight.py @@ -278,12 +278,19 @@ class LightBaker: uv_base = self._get_lightmap_uvtex(mesh, modifier) if uv_base is not None: uv_textures.active = uv_base + # this will copy the UVs to the new UV texture uvtex = uv_textures.new("LIGHTMAPGEN") uv_textures.active = uvtex - self._associate_image_with_uvtex(uvtex, im) - # here we go... + + # if the artist hid any UVs, they will not be baked to... fix this now bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.uv.reveal() + bpy.ops.object.mode_set(mode="OBJECT") + self._associate_image_with_uvtex(uv_textures.active, im) + bpy.ops.object.mode_set(mode="EDIT") + + # prep the uvtex for lightmapping bpy.ops.mesh.select_all(action="SELECT") bpy.ops.uv.average_islands_scale() bpy.ops.uv.pack_islands() From 0b4da161ff3415a11a41fc08dd1a1d8be9777be4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 8 Oct 2017 22:12:31 -0400 Subject: [PATCH 2/3] Only allow LM previews in Object mode Generating lightmap previews in edit mode is nonsense. Also, there is some issue in blender with changing the image assignment programatically while in edit mode, so it's best to just disallow this entirely. --- korman/operators/op_lightmap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/korman/operators/op_lightmap.py b/korman/operators/op_lightmap.py index e67e241..4cad03d 100644 --- a/korman/operators/op_lightmap.py +++ b/korman/operators/op_lightmap.py @@ -23,6 +23,8 @@ class _LightingOperator: @classmethod def poll(cls, context): + if context.mode != "OBJECT": + return False if context.object is not None: return context.scene.render.engine == "PLASMA_GAME" From 5e067388b3d688ad73a42cebf44fa23eb2cb2d81 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 8 Oct 2017 22:55:14 -0400 Subject: [PATCH 3/3] Suppress "Use Vertex Color Paint" for lightmaps This prevents lighting from being rendered to a texture, as noticed by @deledrius --- korman/exporter/etlight.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/korman/exporter/etlight.py b/korman/exporter/etlight.py index 8959f02..6898e2a 100644 --- a/korman/exporter/etlight.py +++ b/korman/exporter/etlight.py @@ -352,13 +352,23 @@ class LightBaker: if isinstance(objs, bpy.types.Object): toggle.track(objs, "hide_render", False) for i in bpy.data.objects: - i.select = i == objs + if i == objs: + # prevents proper baking to texture + for mat in i.data.materials: + toggle.track(mat, "use_vertex_color_paint", False) + i.select = True + else: + i.select = False + if isinstance(i.data, bpy.types.Mesh) and not self._has_valid_material(i): toggle.track(i, "hide_render", True) else: for i in bpy.data.objects: value = i in objs if value: + # prevents proper baking to texture + for mat in i.data.materials: + toggle.track(mat, "use_vertex_color_paint", False) toggle.track(i, "hide_render", False) elif isinstance(i.data, bpy.types.Mesh) and not self._has_valid_material(i): toggle.track(i, "hide_render", True)