Skip to content

Commit 2803f5a

Browse files
Added DDS option to separate alpha (#1510)
1 parent c17b746 commit 2803f5a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

backend/src/nodes/impl/dds.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def save_as_dds(
106106
minimal_compression: bool = False,
107107
maximum_compression: bool = False,
108108
dx9: bool = False,
109+
separate_alpha: bool = False,
109110
):
110111
"""
111112
Saves an image as DDS using texconv.
@@ -145,6 +146,9 @@ def save_as_dds(
145146
if dds_format in __SRGB_DDS_FORMATS:
146147
args.append("-srgbi")
147148

149+
if separate_alpha:
150+
args.append("-sepalpha")
151+
148152
args.append(tempPng)
149153
__run_texconv(args, "Unable to write DDS")
150154
finally:

backend/src/nodes/nodes/image/save_image.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ def __init__(self):
7979
"conditional-enum",
8080
{
8181
"enum": 4,
82-
"conditions": [["jpg", "webp"], "jpg", "jpg", "dds", "dds", "dds"],
82+
"conditions": [
83+
["jpg", "webp"],
84+
"jpg",
85+
"jpg",
86+
"dds",
87+
"dds",
88+
"dds",
89+
"dds",
90+
],
8391
},
8492
)(
8593
SliderInput(
@@ -118,6 +126,9 @@ def __init__(self):
118126
BoolInput("Dithering", default=False).with_id(8),
119127
),
120128
DdsMipMapsDropdown().with_id(10),
129+
group("conditional-enum", {"enum": 10, "conditions": [0]})(
130+
BoolInput("Separate Alpha for Mip Maps", default=False).with_id(13),
131+
),
121132
),
122133
]
123134
self.category = ImageCategory
@@ -143,6 +154,7 @@ def run(
143154
dds_error_metric: DDSErrorMetric,
144155
dds_dithering: bool,
145156
dds_mipmap_levels: int,
157+
dds_separate_alpha: bool,
146158
) -> None:
147159
"""Write an image to the specified path and return write status"""
148160

@@ -180,6 +192,7 @@ def run(
180192
minimal_compression=dds_bc7_compression == BC7Compression.BEST_SPEED,
181193
maximum_compression=dds_bc7_compression == BC7Compression.BEST_QUALITY,
182194
dx9=legacy_dds,
195+
separate_alpha=dds_separate_alpha,
183196
)
184197
return
185198

0 commit comments

Comments
 (0)