Skip to content

Commit

Permalink
Update to 0.19.0
Browse files Browse the repository at this point in the history
Update to 0.19.0
  • Loading branch information
Darkblader24 committed Jun 27, 2021
2 parents 2e171a3 + 4e9af08 commit 0655131
Show file tree
Hide file tree
Showing 63 changed files with 2,518 additions and 2,983 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -15,5 +15,7 @@ resources/google-response.txt
resources/google-response-readable.txt
resources/ignore_version.txt
resources/no_auto_ver_check.txt
resources/icons/supporters/**
resources/supporters.json
.coverage
mmd_tools_local2
mmd_tools_local2
41 changes: 40 additions & 1 deletion README.md
@@ -1,4 +1,4 @@
# Cats Blender Plugin (0.18.0)
# Cats Blender Plugin (0.19.0)

A tool designed to shorten steps needed to import and optimize models into VRChat.
Compatible models are: MMD, XNALara, Mixamo, Source Engine, Unreal Engine, DAZ/Poser, Blender Rigify, Sims 2, Motion Builder, 3DS Max and potentially more
Expand Down Expand Up @@ -315,6 +315,45 @@ It checks for a new version automatically once every day.

## Changelog

#### 0.19.0
- **Fully compatible with Blender 2.93**
- **Translations:**
- **Added Korean translation!**
- Cats is now translated into Korean by a large portion
- To use it, simply change your Blender language to Korean and then restart Blender or select it in the Cats Settings
- Thanks to **Siromori** for contributing the translation! <3
- Added Cats Ui Language setting
- This lets you choose in which language Cats should be displayed
- Setting it to "auto" will choose the current Blender language
- Added button to download the latest Cats Translations
- This feature is for translators to test their translations in the plugin
- If you want to help to translate Cats into any language, please let me (Hotox) know in our Discord
- **Model Options:**
- Added "Connect Bones" button
- Added options to keep merged bones and to merge the bones of visible meshes only
- **Custom Model Creation:**
- Reworked "Attach Mesh" feature, it is much more reliable now
- **General:**
- Fixed translation errors
- Updated mmd_tools
- **Bake: (by feilen)**
- Emission influence baking: fake realtime lighting based on your emissive channel, quest-compatible!
- 'Manual' reprojection mode for Bake: creating new UV maps called 'Target' will allow you to re-bake to a specific layout.
- 'Optimize static shapekeys' option
- Splits your mesh into two skinned meshes, one with all shapekey-influenced geometry,
one with the rest (and fixes the normals in place). Significantly improves GPU performance, especially when a lot of shapekeys are in effect.
Needs the lighting anchor point in Unity to be set to the armature Hips on both, or you'll get lighting artifacts.
- Introduce 'BakeFixer.cs', which is a run-time unity script that hopefully should do the lighting work for you.
- 'Ignore hidden objects' option
- When baking, this will ignore any objects you currently have hidden, making it easier to create different versions of your avatar.
- Apply Current Shapekey Mix option
- Sets your basis to whatever current mix of shapekeys you have. Always-on shapekeys are terrible for performance,
so if you have some that are only intended to customize the character without updates, this will help with that.
- '_bake' shapekeys: any shapekey with '_bake' at the end will be applied and completely removed, allowing the static shapekeys option to work better.
If you're an avatar creator distributing bases, this is recommended for character customization keys!
- Misc: Updated defaults to be in line with updated Quest limits.


#### 0.18.0
- **Added Bake Panel!**
- This is a non-destructive way to produce an optimized variant of (almost) any avatar!
Expand Down
18 changes: 4 additions & 14 deletions __init__.py
Expand Up @@ -30,7 +30,7 @@
'author': 'GiveMeAllYourCats & Hotox',
'location': 'View 3D > Tool Shelf > CATS',
'description': 'A tool designed to shorten steps needed to import and optimize models into VRChat',
'version': (0, 18, 0), # Has to be (x, x, x) not [x, x, x]!! Only change this version and the dev branch var right before publishing the new update!
'version': (0, 19, 0), # Has to be (x, x, x) not [x, x, x]!! Only change this version and the dev branch var right before publishing the new update!
'blender': (2, 80, 0),
'wiki_url': 'https://github.com/michaeldegroot/cats-blender-plugin',
'tracker_url': 'https://github.com/michaeldegroot/cats-blender-plugin/issues',
Expand All @@ -49,7 +49,6 @@
import shutil
import pathlib
import requests
import platform

from . import globs

Expand All @@ -60,27 +59,24 @@
else:
is_reloading = True

import mmd_tools_local

# Load or reload all cats modules
if not is_reloading:
# This order is important
# import mmd_tools_local
import mmd_tools_local
from . import updater
from . import translations
from . import tools
from . import ui
from . import extentions
else:
import importlib
importlib.reload(updater)
importlib.reload(mmd_tools_local)
importlib.reload(translations)
importlib.reload(tools)
importlib.reload(ui)
importlib.reload(extentions)

from .translations import t
from .tools import translations
from .tools.translations import t


# How to update mmd_tools: (outdated, no longer used)
Expand Down Expand Up @@ -264,20 +260,14 @@ def register():
# Register Updater and check for CATS update
updater.register(bl_info, dev_branch, version_str)

# Load translations and check for missing translations
translations.check_missing_translations()

# Set some global settings, first allowed use of globs
globs.dev_branch = dev_branch
globs.version_str = version_str

# Load settings and show error if a faulty installation was deleted recently
show_error = False
try:
tools.settings.load_settings()
except FileNotFoundError:
show_error = True
if show_error:
sys.tracebacklimit = 0
raise ImportError(t('Main.error.restartAndEnable_alt'))

Expand Down
97 changes: 91 additions & 6 deletions extentions.py
Expand Up @@ -4,7 +4,8 @@
from .tools import rootbone as Rootbone
from .tools import settings as Settings
from .tools import importer as Importer
from .translations import t
from .tools import translations as Translations
from .tools.translations import t

from bpy.types import Scene, Material
from bpy.props import BoolProperty, EnumProperty, FloatProperty, IntProperty, CollectionProperty
Expand Down Expand Up @@ -84,18 +85,32 @@ def register():
default=True
)

# Manual
Scene.use_google_only = BoolProperty(
name=t('Scene.use_google_only.label'),
description=t('Scene.use_google_only.desc'),
default=False
)

Scene.keep_merged_bones = BoolProperty(
name='Keep Merged Bones',
description='Select this to keep the bones after merging them to their parents or to the active bone',
default=False
)

Scene.merge_visible_meshes_only = BoolProperty(
name='Merge Visible Meshes Only',
description='Select this to only merge the weights of the visible meshes',
default=False
)

Scene.show_more_options = BoolProperty(
name=t('Scene.show_more_options.label'),
description=t('Scene.show_more_options.desc'),
default=False
)

# Custom Avatar Creation
Scene.merge_mode = EnumProperty(
name=t('Scene.merge_mode.label'),
description=t('Scene.merge_mode.desc'),
Expand Down Expand Up @@ -204,11 +219,35 @@ def register():
Scene.bake_max_tris = IntProperty(
name=t('Scene.max_tris.label'),
description=t('Scene.max_tris.desc'),
default=5000,
default=7500,
min=1,
max=70000
)

Scene.bake_remove_doubles = BoolProperty(
name=t('Scene.decimation_remove_doubles.label'),
description=t('Scene.decimation_remove_doubles.desc'),
default=True
)

Scene.bake_optimize_static = BoolProperty(
name="Optimize Static Shapekeys",
description="Seperate vertices unaffected by shape keys into their own mesh. This adds a drawcall, but comes with a significant GPU cost savings, especially on mobile.",
default=True
)

Scene.bake_cleanup_shapekeys = BoolProperty(
name="Cleanup Shapekeys",
description="Remove backup shapekeys in the final result, e.g. 'Key1 - Reverted' or 'blink_old'",
default=True
)

Scene.bake_create_disable_shapekeys = BoolProperty(
name="Create 'Disable' Shapekeys",
description="Create 'Disable' shapekeys for all but the largest mesh, that cause it to shrink to nothing. Lets you keep toggleable props, without the need for additional meshes.",
default=False
)

# Bake
Scene.bake_resolution = IntProperty(
name=t('Scene.bake_resolution.label'),
Expand Down Expand Up @@ -237,20 +276,31 @@ def register():
("NONE", t("Scene.bake_uv_overlap_correction.none.label"), t("Scene.bake_uv_overlap_correction.none.desc")),
("UNMIRROR", t("Scene.bake_uv_overlap_correction.unmirror.label"), t("Scene.bake_uv_overlap_correction.unmirror.desc")),
("REPROJECT", t("Scene.bake_uv_overlap_correction.reproject.label"), t("Scene.bake_uv_overlap_correction.reproject.desc")),
("MANUAL", "Manual", "Bake will take island information from any UVMap named 'Target' from your meshes, else it will default to the render-active one. Decimation works better when there's only one giant island per loose mesh!")
],
default="UNMIRROR"
)

Scene.bake_device = EnumProperty(
name='Bake Device',
description='Device to bake on. GPU gives a significant speedup, but can cause issues depending on your graphics drivers.',
default='GPU',
items=[
('CPU', 'CPU', 'Perform bakes on CPU (Safe)'),
('GPU', 'GPU', 'Perform bakes on GPU (Fast)')
]
)

Scene.bake_prioritize_face = BoolProperty(
name=t('Scene.bake_prioritize_face.label'),
description=t('Scene.bake_prioritize_face.desc'),
default=True
default=False
)

Scene.bake_face_scale = FloatProperty(
name=t('Scene.bake_face_scale.label'),
description=t('Scene.bake_face_scale.desc'),
default=3.0,
default=2.0,
min=0.5,
max=4.0,
step=0.25,
Expand Down Expand Up @@ -282,6 +332,12 @@ def register():
default=True
)

Scene.bake_diffuse_vertex_colors = BoolProperty(
name="Bake to vertex colors",
description="Rebake to vertex colors after initial bake. Avoids an entire extra texture, if your colors are simple enough. Incorperates AO.",
default=False
)

Scene.bake_preserve_seams = BoolProperty(
name=t('Scene.bake_preserve_seams.label'),
description=t('Scene.bake_preserve_seams.desc'),
Expand All @@ -300,6 +356,18 @@ def register():
default=True
)

Scene.bake_apply_keys = BoolProperty(
name="Apply current shapekey mix",
description="When selected, currently active shape keys will be applied to the basis. This is extremely beneficial to performance if your avatar is intended to 'default' to one shapekey mix, as having active shapekeys all the time is expensive. Keys ending in '_bake' are always applied to the basis and removed completely, regardless of this option.",
default=False
)

Scene.bake_ignore_hidden = BoolProperty(
name="Ignore hidden objects",
description="Ignore currently hidden objects when copying",
default=True
)

Scene.bake_pass_ao = BoolProperty(
name=t('Scene.bake_pass_ao.label'),
description=t('Scene.bake_pass_ao.desc'),
Expand All @@ -318,6 +386,18 @@ def register():
default=False
)

Scene.bake_emit_indirect = BoolProperty(
name="Bake projected light",
description="Bake the effect of emission on nearby surfaces. Results in much more realistic lighting effects, but can animate less well.",
default=False
)

Scene.bake_emit_exclude_eyes = BoolProperty(
name="Exclude eyes",
description="Bakes the effect of any eye glow onto surrounding objects, but not vice-versa. Improves animation when eyes are moving around..",
default=True
)

Scene.bake_diffuse_alpha_pack = EnumProperty(
name=t('Scene.bake_diffuse_alpha_pack.label'),
description=t('Scene.bake_diffuse_alpha_pack.desc'),
Expand Down Expand Up @@ -405,7 +485,7 @@ def register():
description=t('Scene.max_tris.desc'),
default=70000,
min=1,
max=200000
max=500000
)

# Eye Tracking
Expand Down Expand Up @@ -660,7 +740,12 @@ def register():
default=False,
update=Settings.update_settings
)

Scene.ui_lang = EnumProperty(
name=t('Scene.ui_lang.label'),
description=t('Scene.ui_lang.desc'),
items=Translations.get_languages_list,
update=Translations.update_ui
)
Scene.debug_translations = BoolProperty(
name=t('Scene.debug_translations.label'),
description=t('Scene.debug_translations.desc'),
Expand Down
50 changes: 50 additions & 0 deletions extern_tools/BakeFixer.cs
@@ -0,0 +1,50 @@
#if UNITY_EDITOR
using System.Text;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor;
using System;
using System.IO;

[InitializeOnLoad]
public class BakeFixer : ScriptableObject
{
static BakeFixer()
{
EditorApplication.hierarchyChanged += Update;
Debug.Log("BakeFixer loaded");
}

static void Update()
{
// Get the path of this script
Scene scene = SceneManager.GetActiveScene();
var game_obj = scene.GetRootGameObjects();
foreach (var obj in game_obj)
{
// For each armature on the scene who owns "Armature", "Static" and "Body",
// get their SkinnedMeshRenderer components and edit the anchor point
if (obj.transform.Find("Armature") != null &&
obj.transform.Find("Body") != null &&
obj.transform.Find("Static") != null)
{
var body = obj.transform.Find("Body");
var stat = obj.transform.Find("Static");
var arm = obj.transform.Find("Armature");
var smr_body = (SkinnedMeshRenderer)body.GetComponent(typeof(SkinnedMeshRenderer));
var smr_stat = (SkinnedMeshRenderer)stat.GetComponent(typeof(SkinnedMeshRenderer));

if (arm.childCount > 0) {
Debug.Log("Altering anchor point for: " + obj.name);
var hips = arm.GetChild(0);

// Set lightprobe anchor
smr_body.probeAnchor = hips;
smr_stat.probeAnchor = hips;
}
}
}
}
}
#endif

0 comments on commit 0655131

Please sign in to comment.