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. 14
      korman/operators/op_lightmap.py
  2. 14
      korman/ui/modifiers/render.py

14
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"}
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)]
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"}

14
korman/ui/modifiers/render.py

@ -202,18 +202,18 @@ 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!
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)
if tex.image.name == im_name:
layout.template_preview(tex, show_buttons=False)
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)
if tex.image.name == im_name:
layout.template_preview(tex, show_buttons=False)
def rtshadow(modifier, layout, context):
split = layout.split()

Loading…
Cancel
Save