自定义SP导出器
功能
- 对Texture Set进行命名验证,以管理名称和存储位置的一致性
- 根据我们指定的类型导出限制分辨率大小的Texture
- 根据Texture类型自动导出到不同文件夹

自定义导出器
命名规则验证
检查每个Texture的命名规则,将Texture分配不同的类型和不同的文件夹。
突出显示并自动选择当前类型的所有Texture。

角色Texture自动验证

武器Texture自动验证
命名规则验证
def validate_texture_sets(self):
asset_type = self.asset_type_cmbx.currentText()
self.textsets_with_overbudget_res = []
for i, texture_set in enumerate(self.all_texture_sets):
res_is_valid, res_validation_details = module_validation_resolution.validate_res(asset_type, texture_set.get_resolution())
validation_item = QTableWidgetItem()
export_checkbox = self.textset_table.cellWidget(i, 0)
if res_is_valid:
name_is_valid, name_validation_details = module_validation_name.validate_name(asset_type, texture_set.name())
if name_is_valid:
validation_item.setIcon(self.icon_validation_ok)
validation_item.setToolTip(f"Texture set validation are AVAILABLE for texture set {i+1} \
\n{texture_set.name()}")
export_checkbox.setToolTip(f"Specify if Texture Set #{i+1}: {texture_set.name()} \
should be processed during the export or skipped")
else:
validation_item.setIcon(self.icon_validation_fail)
validation_item.setToolTip(f"Texture set Name validation is FAILED for texture set {i+1} \
\n{texture_set.name()} \
\nReason: {name_validation_details} \
\nExport of this texture is disabled until it's valid")
export_checkbox.setToolTip(f"Texture set Name validation is FAILED for texture set {i+1} \
\n{texture_set.name()} \
\nReason: {name_validation_details} \
\nExport of this texture is disabled until it's valid")
else:
validation_item.setIcon(self.icon_validation_fail)
validation_item.setToolTip(f"Texture set Resolution validation is FAILED for texture set {i+1} \
\n{texture_set.name()} \
\nReason: {res_validation_details} \
\nExport of this texture is disabled until it's valid")
export_checkbox.setToolTip(f"Texture set Resolution validation is FAILED for texture set {i+1} \
\n{texture_set.name()} \
\nReason: {res_validation_details} \
\nExport of this texture is disabled until it's valid")
self.textsets_with_overbudget_res.append(texture_set)
export_checkbox.setChecked(res_is_valid and name_is_valid)
export_checkbox.setEnabled(res_is_valid and name_is_valid)
self.textset_table.setItem(i, 5, validation_item)
if len(self.textsets_with_overbudget_res) > 0:
self.open_dialog_res_confirmation()
命名验证的代码
分辨率大小验证
导出器会验证从 Painter 导出Texture是否遵循指定的分辨率预算,并防止项目中出现任何过高分辨率的Texture。
分辨率验证
def open_dialog_res_confirmation(self):
settings = QtCore.QSettings()
if settings.value("diaglog_window_checkbox_state", QtCore.Qt.Unchecked) == QtCore.Qt.Unchecked:
dialog = DiaglogWindow(self.icon_main_window)
if dialog.exec_() == QDialog.Accepted:
self.apply_required_res()
self.on_refresh_textset_table()
else:
substance_painter.logging.log(severity=substance_painter.logging.WARNING,
channel="Custom Exporter",
message="Remember to manually fix the resolution in the teture setting. \
\nValidation error would present fro export")
else:
substance_painter.logging.log(severity=substance_painter.logging.INFO,
channel="Custom Exporter",
message="dialog for resolution autofix was not trigger as per user settings")
def apply_required_res(self):
required_width, required_height = module_validation_resolution.get_required_res_from_asset_type(self.asset_type_cmbx.currentText())
required_resolution = substance_painter.textureset.Resolution(required_width, required_height)
for texture_set in self.textsets_with_overbudget_res:
original_res = texture_set.get_resolution()
texture_set.set_resolution(required_resolution)
substance_painter.logging.log(severity=substance_painter.logging.INFO,
channel="Custom Exporter",
message=f"Applied required resolution for texture set {texture_set.name()} \
\nWas: {original_res}, Now:{required_resolution}")
命名规则验证代码
导出器
将不同的Texture根据其自身类型导出到不同的文件夹。
自动导出Texture
def on_export_requested(self):
if self.all_texture_sets != None:
for i in range(len(self.all_texture_sets)):
should_export = self.textset_table.cellWidget(i, 0).isChecked()
if not should_export:
continue
textset_name = self.textset_table.item(i, 1).text()
shader_type = self.textset_table.cellWidget(i, 2).currentText()
export_path = self.textset_table.item(i, 4).text()
module_export.export_textures(textset_name, shader_type, export_path)
命名规则验证代码
截图


