Browse Source

Merge pull request #77 from Hoikas/moar-lightmapz

Fix Lightmapping Issues
pull/82/head
Adam Johnson 7 years ago committed by GitHub
parent
commit
ba98e029e2
  1. 23
      korman/exporter/etlight.py
  2. 2
      korman/operators/op_lightmap.py

23
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()
@ -345,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)

2
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"

Loading…
Cancel
Save