Browse Source

Fix CubeMap Bug

* Adds a sanity check that raises an error if a CubeMap doesn't have an image.
pull/374/head
Patrick Dulebohn 2 years ago
parent
commit
695674f8e5
  1. 45
      korman/exporter/material.py

45
korman/exporter/material.py

@ -701,27 +701,30 @@ class MaterialConverter:
layer.texture = pl_env.key layer.texture = pl_env.key
def export_cubic_env(self, bo, layer, texture): def export_cubic_env(self, bo, layer, texture):
width, height = texture.image.size if texture.image == None:
raise ExportError("CubeMap '{}' has no cube image!".format(texture.name))
# Sanity check: the image here should be 3x2 faces, so we should not have any else:
# dam remainder... width, height = texture.image.size
if width % 3 != 0:
raise ExportError("CubeMap '{}' width must be a multiple of 3".format(texture.image.name)) # Sanity check: the image here should be 3x2 faces, so we should not have any
if height % 2 != 0: # dam remainder...
raise ExportError("CubeMap '{}' height must be a multiple of 2".format(texture.image.name)) if width % 3 != 0:
raise ExportError("CubeMap '{}' width must be a multiple of 3".format(texture.image.name))
# According to PlasmaMAX, we don't give a rip about UVs... if height % 2 != 0:
layer.UVWSrc = plLayerInterface.kUVWReflect raise ExportError("CubeMap '{}' height must be a multiple of 2".format(texture.image.name))
layer.state.miscFlags |= hsGMatState.kMiscUseReflectionXform
# According to PlasmaMAX, we don't give a rip about UVs...
# Well, this is kind of sad... layer.UVWSrc = plLayerInterface.kUVWReflect
# Back before the texture cache existed, all the image work was offloaded layer.state.miscFlags |= hsGMatState.kMiscUseReflectionXform
# to a big "finalize" save step to prevent races. The texture cache would
# prevent that as well, so we could theoretically slice-and-dice the single # Well, this is kind of sad...
# image here... but... meh. Offloading taim. # Back before the texture cache existed, all the image work was offloaded
self.export_prepared_image(texture=texture, owner=layer, # to a big "finalize" save step to prevent races. The texture cache would
alpha_type=TextureAlpha.opaque, mipmap=True, # prevent that as well, so we could theoretically slice-and-dice the single
allowed_formats={"DDS"}, is_cube_map=True, tag="cubemap") # image here... but... meh. Offloading taim.
self.export_prepared_image(texture=texture, owner=layer, indent=3,
alpha_type=TextureAlpha.opaque, mipmap=True,
allowed_formats={"DDS"}, is_cube_map=True, tag="cubemap")
def export_dynamic_env(self, bo, layer, texture, pl_class): def export_dynamic_env(self, bo, layer, texture, pl_class):

Loading…
Cancel
Save