Browse Source

Allow previewing vertex lighting from lightmap mod.

This is the beginning of a workflow loop to (hopefully) improve the
performance of exporting Ages with expensive lighting. This commit
allows you to generate the autocolor layer in the Korman UI and rename
it to `col` to prevent needless re-baking.
pull/261/head
Adam Johnson 3 years ago
parent
commit
599dccb872
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 4
      korman/operators/op_lightmap.py
  2. 4
      korman/ui/modifiers/render.py

4
korman/operators/op_lightmap.py

@ -44,10 +44,14 @@ class LightmapAutobakePreviewOperator(_LightingOperator, bpy.types.Operator):
self.report({"INFO"}, "No valid lights found to bake.")
return {"FINISHED"}
if context.object.plasma_modifiers.lightmap.bake_type == "lightmap":
tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW")
if tex is None:
tex = bpy.data.textures.new("LIGHTMAPGEN_PREVIEW", "IMAGE")
tex.extension = "CLIP"
tex.image = bpy.data.images["{}_LIGHTMAPGEN.png".format(context.active_object.name)]
else:
for i in context.object.data.vertex_colors:
i.active = i.name == "autocolor"
return {"FINISHED"}

4
korman/ui/modifiers/render.py

@ -202,13 +202,13 @@ def lightmap(modifier, layout, context):
layout.label("Transparent objects cannot be lightmapped.", icon="ERROR")
else:
col = layout.column()
col.active = is_texture
operator = col.operator("object.plasma_lightmap_preview", "Preview Lightmap", icon="RENDER_STILL")
col.operator("object.plasma_lightmap_preview", "Preview Lightmap" if is_texture else "Preview Vertex Colors", icon="RENDER_STILL")
# Kind of clever stuff to show the user a preview...
# We can't show images, so we make a hidden ImageTexture called LIGHTMAPGEN_PREVIEW. We check
# the backing image name to see if it's for this lightmap. If so, you have a preview. If not,
# well... It was nice knowing you!
if is_texture:
tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW")
if tex is not None and tex.image is not None:
im_name = "{}_LIGHTMAPGEN.png".format(context.active_object.name)

Loading…
Cancel
Save