Skip to content

Commit

Permalink
Remove Scalp (fix opaque scalp)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbui78 committed Aug 27, 2024
1 parent 8641166 commit f641de7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
2 changes: 2 additions & 0 deletions DazStudioPlugin/DzRobloxAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ void DzRobloxAction::writeConfiguration()
writer.addMember("Texture Size", m_nRobloxTextureSize);
writer.addMember("Texture Bake Quality", m_nBlenderTextureBakeQuality);
writer.addMember("Hidden Surface Removal", m_bHiddenSurfaceRemoval);
writer.addMember("Remove Scalp Material", m_bRemoveScalp);

if (true)
{
Expand Down Expand Up @@ -1504,6 +1505,7 @@ bool DzRobloxAction::readGui(DZ_BRIDGE_NAMESPACE::DzBridgeDialog* BridgeDialog)
m_bEnableBreastsGone = pRobloxDialog->m_wBreastsGoneCheckbox->isChecked();
m_bBakeSingleOutfit = pRobloxDialog->m_wBakeSingleOutfitCheckbox->isChecked();
m_bHiddenSurfaceRemoval = pRobloxDialog->m_wHiddenSurfaceRemovalCheckbox->isChecked();
m_bRemoveScalp = pRobloxDialog->m_wRemoveScalpMaterialCheckbox->isChecked();

// modesty overlay
QVariant vModestyData = pRobloxDialog->m_wModestyOverlayCombo->itemData(pRobloxDialog->m_wModestyOverlayCombo->currentIndex());
Expand Down
1 change: 1 addition & 0 deletions DazStudioPlugin/DzRobloxAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class DzRobloxAction : public DZ_BRIDGE_NAMESPACE::DzBridgeAction {
int m_nReplaceEyebrows = 0;
int m_nReplaceEyelashes = 0;
bool m_bHiddenSurfaceRemoval = false;
bool m_bRemoveScalp = false;

friend class DzRobloxUtils;

Expand Down
12 changes: 9 additions & 3 deletions DazStudioPlugin/DzRobloxDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,26 @@ DzRobloxDialog::DzRobloxDialog(QWidget* parent) :
QLabel* wReplacementPartsRowLabel = new QLabel(tr("Replacement Assets"));

// Accessory Export Options
QHBoxLayout* wClothingOptionsLayout = new QHBoxLayout();
QVBoxLayout* wClothingOptionsLayout = new QVBoxLayout();
m_wBakeSingleOutfitCheckbox = new QCheckBox(tr("Merge all clothing together"));
QString sBakeSingleOutfit = tr("Merge all clothing and hair items togother so that they use a single Roblox clothing slot");
m_wBakeSingleOutfitCheckbox->setToolTip(sBakeSingleOutfit);
m_wBakeSingleOutfitCheckbox->setWhatsThis(sBakeSingleOutfit);
m_wBakeSingleOutfitCheckbox->setChecked(false);
m_wHiddenSurfaceRemovalCheckbox = new QCheckBox(tr("Hidden Geometry Removal"));
m_wHiddenSurfaceRemovalCheckbox = new QCheckBox(tr("Remove Hidden Geometry"));
QString sHiddenSurfaceRemoval = tr("Remove unnecessary triangles which are hidden underneath other triangles and visible (Experimental)");
m_wHiddenSurfaceRemovalCheckbox->setToolTip(sHiddenSurfaceRemoval);
m_wHiddenSurfaceRemovalCheckbox->setWhatsThis(sHiddenSurfaceRemoval);
m_wHiddenSurfaceRemovalCheckbox->setChecked(false);
QString sRemoveScalp = tr("Remove scalp geometry from hair assets. May fix opaque scalp issues.");
m_wRemoveScalpMaterialCheckbox = new QCheckBox(tr("Remove Scalp"));
m_wRemoveScalpMaterialCheckbox->setToolTip(sRemoveScalp);
m_wRemoveScalpMaterialCheckbox->setToolTip(sRemoveScalp);
m_wRemoveScalpMaterialCheckbox->setChecked(true);
wClothingOptionsLayout->addWidget(m_wBakeSingleOutfitCheckbox);
wClothingOptionsLayout->addWidget(m_wHiddenSurfaceRemovalCheckbox);
QLabel* wLayeredClothingRowLabel = new QLabel(tr("Layered Clothing"));
wClothingOptionsLayout->addWidget(m_wRemoveScalpMaterialCheckbox);
QLabel* wLayeredClothingRowLabel = new QLabel(tr("Accessories"));

// Add GUI to layout
mainLayout->insertRow(1, "Roblox Output Folder", robloxOutputFolderLayout);
Expand Down
1 change: 1 addition & 0 deletions DazStudioPlugin/DzRobloxDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected slots:
QComboBox* m_wEyelashReplacement;

QCheckBox* m_wHiddenSurfaceRemovalCheckbox;
QCheckBox* m_wRemoveScalpMaterialCheckbox;

virtual void refreshAsset() override;

Expand Down
Binary file modified DazStudioPlugin/Resources/plugindata.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion DazStudioPlugin/real_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define VER_MAJOR 2024
#define VER_MINOR 1
#define VER_REV 3
#define VER_BUILD 255
#define VER_BUILD 256

#define TOSTRING(x) #x
#define VERSION_STRING TOSTRING(VER_MAJOR) "." TOSTRING(VER_MINOR) "." TOSTRING(VER_REV) "." TOSTRING(VER_BUILD)
32 changes: 32 additions & 0 deletions PluginData/blender_dtu_to_r15_accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def _main(argv):
hidden_surface_removal = dtu_dict["Hidden Surface Removal"]
else:
hidden_surface_removal = False
if "Remove Scalp Material" in dtu_dict:
remove_scalp_material = dtu_dict["Remove Scalp Material"]
else:
remove_scalp_material = False

if "Has Animation" in dtu_dict:
bHasAnimation = dtu_dict["Has Animation"]
Expand Down Expand Up @@ -279,6 +283,34 @@ def _main(argv):
else:
main_item.name = roblox_asset_name

if remove_scalp_material:
hair_obj_list = []
for obj in bpy.data.objects:
if obj.type == 'MESH' and "StudioPresentationType" in obj:
if "hair" in obj["StudioPresentationType"].lower():
hair_obj_list.append(obj)
for obj in hair_obj_list:
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='OBJECT')
for face in obj.data.polygons:
material_name = obj.material_slots[face.material_index].material.name
# fuzzy match scalp and skullcap
# exact match for "Cap"
if ("scalp" in material_name.lower() or
"skullcap" in material_name.lower() or
"Cap" == material_name
):
print("DEBUG: SCALP REMOVER: material_name=" + material_name)
for vert_index in face.vertices:
obj.data.vertices[vert_index].select = True
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.delete(type='VERT')
bpy.ops.object.mode_set(mode='OBJECT')

# convert to texture atlas
safe_material_names_list = []
for obj in bpy.data.objects:
Expand Down

0 comments on commit f641de7

Please sign in to comment.