Browse Source

Add the ability to control dynamic envmap export

This provides the artist the ability to disable exporting layers that
would be DynamicCamMap (fast) in MOUL but DynamicEnvMap (slow) in PotS
in one fell swoop. Please note that disabling env map exporting will NOT
prevent waveset environment maps from exporting.
pull/125/head
Adam Johnson 6 years ago
parent
commit
f9842789bf
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 4
      korman/exporter/convert.py
  2. 34
      korman/exporter/material.py
  3. 7
      korman/operators/op_export.py
  4. 1
      korman/ui/ui_world.py

4
korman/exporter/convert.py

@ -350,6 +350,10 @@ class Exporter:
self.mgr.save_age(Path(self._op.filepath))
self.image.save()
@property
def envmap_method(self):
return bpy.context.scene.world.plasma_age.envmap_method
@property
def texcache_path(self):
age = bpy.context.scene.world.plasma_age

34
korman/exporter/material.py

@ -139,13 +139,41 @@ class MaterialConverter:
"transformCtl": self._export_layer_transform_animation,
}
def _can_export_texslot(self, slot):
if slot is None or not slot.use:
return False
texture = slot.texture
if texture is None or texture.type not in self._tex_exporters:
return False
# Per-texture type rules
if texture.type == "ENVIRONMENT_MAP":
envmap = texture.environment_map
# If this is a static, image based cube map, then we will allow it
# to be exported anyway. Note that as of the writing of this code,
# that is kind of pointless because CEMs are not yet implemented...
if envmap.source == "IMAGE_FILE":
return True
# Now for the ruelz
method, ver = self._exporter().envmap_method, self._mgr.getVer()
if method == "skip":
return False
elif method == "dcm2dem":
return True
elif method == "perengine":
return (ver >= pvMoul and envmap.mapping == "PLANE") or envmap.mapping == "CUBE"
else:
raise NotImplementedError(method)
else:
return True
def export_material(self, bo, bm):
"""Exports a Blender Material as an hsGMaterial"""
self._report.msg("Exporting Material '{}'", bm.name, indent=1)
hsgmat = self._mgr.add_object(hsGMaterial, name=bm.name, bl=bo)
slots = [(idx, slot) for idx, slot in enumerate(bm.texture_slots) if slot is not None and slot.use \
and slot.texture is not None and slot.texture.type in self._tex_exporters]
slots = [(idx, slot) for idx, slot in enumerate(bm.texture_slots) if self._can_export_texslot(slot)]
# There is a major difference in how Blender and Plasma handle stencils.
# In Blender, the stencil is on top and applies to every layer below is. In Plasma, the stencil
@ -453,6 +481,8 @@ class MaterialConverter:
texture = slot.texture
bl_env = texture.environment_map
if bl_env.source in {"STATIC", "ANIMATED"}:
# NOTE: It is assumed that if we arrive here, we are at lease dcm2dem on the
# environment map export method. You're welcome!
if bl_env.mapping == "PLANE" and self._mgr.getVer() >= pvMoul:
pl_env = plDynamicCamMap
else:

7
korman/operators/op_export.py

@ -64,6 +64,13 @@ class ExportOperator(bpy.types.Operator):
("force_lightmap", "Force Lightmap Bake", "All static lighting is baked as lightmaps (slower export)")],
"default": "bake"}),
"envmap_method": (EnumProperty, {"name": "Environment Maps",
"description": "Environment Map Settings",
"items": [("skip", "Don't Export EnvMaps", "Environment Maps are not exported (the age runs faster)"),
("dcm2dem", "Downgrade Planar EnvMaps", "When the engine doesn't support them, Planar Environment Maps are downgraded to Cube Maps"),
("perengine", "Export Supported EnvMaps", "Only environment maps supported by the selected game engine are exported")],
"default": "dcm2dem"}),
"export_active": (BoolProperty, {"name": "INTERNAL: Export currently running",
"default": False,
"options": {"SKIP_SAVE"}}),

1
korman/ui/ui_world.py

@ -143,6 +143,7 @@ class PlasmaAgePanel(AgeButtonsPanel, bpy.types.Panel):
col.prop(age, "use_texture_page")
layout.separator()
layout.prop(age, "envmap_method")
layout.prop(age, "lighting_method")
layout.prop(age, "texcache_method")

Loading…
Cancel
Save