Browse Source

Combine Lightmap and Vertex Color

* Adds option to use both lightmap and VCol in the Bake Lighting modifier
pull/402/head
Patrick Dulebohn 3 months ago
parent
commit
3819b62d2c
  1. 2
      korman/exporter/mesh.py
  2. 5
      korman/properties/modifiers/render.py
  3. 4
      korman/ui/modifiers/render.py

2
korman/exporter/mesh.py

@ -384,7 +384,7 @@ class MeshConverter(_MeshManager):
# Locate relevant vertex color layers now...
lm = bo.plasma_modifiers.lightmap
color = None if lm.bake_lightmap else self._find_vtx_color_layer(mesh.tessface_vertex_colors)
color = None if lm.bake_lightmap and lm.bake_type == "lightmap" else self._find_vtx_color_layer(mesh.tessface_vertex_colors)
alpha = self._find_vtx_alpha_layer(mesh.tessface_vertex_colors)
# Convert Blender faces into things we can stuff into libHSPlasma

5
korman/properties/modifiers/render.py

@ -430,6 +430,7 @@ class PlasmaLightMapGen(idprops.IDPropMixin, PlasmaModifierProperties, PlasmaMod
items=[
("lightmap", "Lightmap Texture", "Bakes lighting to a lightmap texture"),
("vcol", "Vertex Colors", "Bakes lighting to vertex colors"),
("lmandvcol", "Lightmap with Vertex Colors", "Bakes both a lightmap and vertex colors")
],
options=set())
@ -465,6 +466,8 @@ class PlasmaLightMapGen(idprops.IDPropMixin, PlasmaModifierProperties, PlasmaMod
return True
elif self.bake_type == "lightmap" and age.lighting_method == "bake":
return True
elif self.bake_type == "lmandvcol" and age.lighting_method == "bake":
return True
else:
return False
else:
@ -475,7 +478,7 @@ class PlasmaLightMapGen(idprops.IDPropMixin, PlasmaModifierProperties, PlasmaMod
return self.bake_lightmap
def export(self, exporter, bo, so):
# If we're exporting vertex colors, who gives a rat's behind?
# If we're exporting *only* vertex colors, who gives a rat's behind?
if not self.bake_lightmap:
return

4
korman/ui/modifiers/render.py

@ -224,10 +224,10 @@ def lighting(modifier, layout, context):
def lightmap(modifier, layout, context):
pl_scene = context.scene.plasma_scene
is_texture = modifier.bake_type == "lightmap"
is_texture = modifier.bake_type == "lightmap" or modifier.bake_type == "lmandvcol"
layout.prop(modifier, "bake_type")
if modifier.bake_type == "vcol":
if modifier.bake_type == "vcol" or modifier.bake_type == "lmandvcol":
col_layer = next((i for i in modifier.id_data.data.vertex_colors if i.name.lower() in _VERTEX_COLOR_LAYERS), None)
if col_layer is not None:
layout.label("Mesh color layer '{}' will override this lighting.".format(col_layer.name), icon="ERROR")

Loading…
Cancel
Save