Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer RGBA over CI toggle for automatic texture format #299

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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")
Lilaa3 marked this conversation as resolved.
Show resolved Hide resolved


class Fast64_Properties(bpy.types.PropertyGroup):
Expand Down
14 changes: 7 additions & 7 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[:]
Expand All @@ -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]
Dragorn421 marked this conversation as resolved.
Show resolved Hide resolved
if isGreyscale:
if tex.size[0] * tex.size[1] > 4096:
if tex_size > 4096:
if not hasAlpha1bit:
texFormat = "I4"
else:
Expand All @@ -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"
Expand Down