diff --git a/__init__.py b/__init__.py index a4ef80e71..0da2ad8a4 100644 --- a/__init__.py +++ b/__init__.py @@ -212,6 +212,7 @@ def draw(self, context): prop_split(col, context.scene, "gameEditorMode", "Game") col.prop(context.scene, "exportHiddenGeometry") col.prop(context.scene, "fullTraceback") + col.prop(context.scene.fast64.settings, "prefer_ci_over_rgba") prop_split(col, context.scene.fast64.settings, "anim_range_choice", "Anim Range") @@ -267,6 +268,7 @@ class Fast64Settings_Properties(bpy.types.PropertyGroup): ], default="intersect_action_and_scene", ) + prefer_ci_over_rgba: bpy.props.BoolProperty(name="Prefer Color Indexed Over RGBA") class Fast64_Properties(bpy.types.PropertyGroup): diff --git a/fast64_internal/f3d/f3d_material.py b/fast64_internal/f3d/f3d_material.py index da1794e50..b66ab5ab4 100644 --- a/fast64_internal/f3d/f3d_material.py +++ b/fast64_internal/f3d/f3d_material.py @@ -3377,7 +3377,7 @@ def getOptimalFormat(tex, curFormat, isMultitexture): isGreyscale = True hasAlpha4bit = False hasAlpha1bit = False - pixelValues = [] + pixelValues = set() # N64 is -Y, Blender is +Y pixels = tex.pixels[:] @@ -3392,12 +3392,11 @@ def getOptimalFormat(tex, curFormat, isMultitexture): hasAlpha4bit = True if color[3] < 0.5: hasAlpha1bit = True - pixelColor = getRGBA16Tuple(color) - if pixelColor not in pixelValues: - pixelValues.append(pixelColor) + pixelValues.add(getRGBA16Tuple(color)) + tex_size = tex.size[0] * tex.size[1] if isGreyscale: - if tex.size[0] * tex.size[1] > 4096: + if tex_size > 4096: if not hasAlpha1bit: texFormat = "I4" else: @@ -3408,9 +3407,10 @@ def getOptimalFormat(tex, curFormat, isMultitexture): else: texFormat = "IA8" else: - if len(pixelValues) <= 16: + prefer_ci_over_rgba = bpy.context.scene.fast64.settings.prefer_ci_over_rgba + if (prefer_ci_over_rgba and len(pixelValues) <= 16) or (len(pixelValues) <= 16 and tex_size > 2048): texFormat = "CI4" - elif len(pixelValues) <= 256 and tex.size[0] * tex.size[1] <= 2048: + elif prefer_ci_over_rgba and len(pixelValues) <= 256 and tex_size <= 2048: texFormat = "CI8" else: texFormat = "RGBA16"