Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lilxyzw committed Aug 8, 2021
1 parent b8e2ecf commit 6cecb05
Show file tree
Hide file tree
Showing 44 changed files with 728 additions and 473 deletions.
144 changes: 75 additions & 69 deletions Assets/lilToon/Editor/lang.txt

Large diffs are not rendered by default.

711 changes: 417 additions & 294 deletions Assets/lilToon/Editor/lilInspector.cs

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions Assets/lilToon/Editor/lilStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ public class lilStartup {
[InitializeOnLoadMethod]
static void lilStartupMethod()
{
string editorPath = lilToonInspector.GetEditorPath();
string editorSettingPath = lilToonInspector.GetEditorSettingPath();
string settingFolderPath = lilToonInspector.GetSettingFolderPath();
string shaderSettingHLSLPath = lilToonInspector.GetShaderSettingHLSLPath();

// Editor
if(!File.Exists(lilToonInspector.rspPath))
{
StreamWriter sw = new StreamWriter(lilToonInspector.rspPath,true);
sw.Write("-r:System.Drawing.dll\n-define:SYSTEM_DRAWING");
sw.Close();
AssetDatabase.Refresh();
AssetDatabase.ImportAsset(lilToonInspector.editorPath);
AssetDatabase.ImportAsset(editorPath);
}

StreamReader sr = new StreamReader(lilToonInspector.rspPath);
Expand All @@ -31,14 +36,14 @@ static void lilStartupMethod()
StreamWriter sw = new StreamWriter(lilToonInspector.rspPath,true);
sw.Write("\n-r:System.Drawing.dll");
sw.Close();
AssetDatabase.ImportAsset(lilToonInspector.editorPath);
AssetDatabase.ImportAsset(editorPath);
}
if(!s.Contains("define:SYSTEM_DRAWING"))
{
StreamWriter sw = new StreamWriter(lilToonInspector.rspPath,true);
sw.Write("\n-define:SYSTEM_DRAWING");
sw.Close();
AssetDatabase.ImportAsset(lilToonInspector.editorPath);
AssetDatabase.ImportAsset(editorPath);
}

AssetDatabase.Refresh();
Expand All @@ -53,14 +58,14 @@ static void lilStartupMethod()
lilToonInspector.edSet.languageNum = lilToonInspector.InitializeLanguage(lilToonInspector.edSet.languageNum);

// Setting Folder
if(!Directory.Exists(lilToonInspector.settingFolderPath)) Directory.CreateDirectory(lilToonInspector.settingFolderPath);
if(!Directory.Exists(settingFolderPath)) Directory.CreateDirectory(settingFolderPath);

if(!File.Exists(lilToonInspector.shaderSettingHLSLPath))
if(!File.Exists(shaderSettingHLSLPath))
{
StreamWriter sw = new StreamWriter(lilToonInspector.shaderSettingHLSLPath,false);
StreamWriter sw = new StreamWriter(shaderSettingHLSLPath,false);
sw.Write("//INITIALIZE\r\n#ifndef LIL_SETTING_INCLUDED\r\n#define LIL_SETTING_INCLUDED\r\n\r\n#define LIL_FEATURE_MAIN_TONE_CORRECTION\r\n#define LIL_FEATURE_SHADOW\r\n#define LIL_FEATURE_TEX_SHADOW_STRENGTH\r\n#define LIL_FEATURE_EMISSION_1ST\r\n#define LIL_FEATURE_NORMAL_1ST\r\n#define LIL_FEATURE_MATCAP\r\n#define LIL_FEATURE_TEX_MATCAP_MASK\r\n#define LIL_FEATURE_RIMLIGHT\r\n#define LIL_FEATURE_TEX_RIMLIGHT_COLOR\r\n#define LIL_FEATURE_TEX_OUTLINE_COLOR\r\n#define LIL_FEATURE_TEX_OUTLINE_WIDTH\r\n\r\n#endif");
sw.Close();
AssetDatabase.ImportAsset(lilToonInspector.shaderSettingHLSLPath);
AssetDatabase.ImportAsset(shaderSettingHLSLPath);
Debug.Log("Generate setting hlsl file");
}

Expand Down Expand Up @@ -107,14 +112,14 @@ static void lilStartupMethod()
}

// Delete old file
if(File.Exists(lilToonInspector.editorSettingPath))
if(File.Exists(editorSettingPath))
{
string[] GUIDs = AssetDatabase.FindAssets("t:lilToonEditorSetting");
foreach(string GUID in GUIDs)
{
AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(GUID));
}
AssetDatabase.DeleteAsset(lilToonInspector.editorSettingPath);
AssetDatabase.DeleteAsset(editorSettingPath);
}

AssetDatabase.SaveAssets();
Expand Down
6 changes: 4 additions & 2 deletions Assets/lilToon/Editor/lilToonAssetPostprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class lilToonAssetPostprocessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
string shaderSettingHLSLPath = lilToonInspector.GetShaderSettingHLSLPath();

// Runs only when there is no user action
if(Event.current != null) return;

Expand All @@ -34,9 +36,9 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse

// Check shader setting
string shaderSettingString = "//INITIALIZE";
if(File.Exists(lilToonInspector.shaderSettingHLSLPath))
if(File.Exists(shaderSettingHLSLPath))
{
StreamReader srSetting = new StreamReader(lilToonInspector.shaderSettingHLSLPath);
StreamReader srSetting = new StreamReader(shaderSettingHLSLPath);
shaderSettingString = srSetting.ReadToEnd();
srSetting.Close();
}
Expand Down
13 changes: 8 additions & 5 deletions Assets/lilToon/Editor/lilToonEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public class lilRefreshShaders : MonoBehaviour
[MenuItem("Assets/lilToon/Refresh shaders", false, 20)]
static void RefreshShaders()
{
string[] shaderGuids = AssetDatabase.FindAssets("t:shader", lilToonInspector.shaderFolderPaths);
string[] shaderFolderPaths = lilToonInspector.GetShaderFolderPaths();
string shaderPipelinePath = lilToonInspector.GetShaderPipelinePath();
string shaderSettingPath = lilToonInspector.GetShaderSettingPath();
string[] shaderGuids = AssetDatabase.FindAssets("t:shader", shaderFolderPaths);
if(shaderGuids.Length > 33)
{
// Render Pipeline
Expand All @@ -42,8 +45,8 @@ static void RefreshShaders()
string shaderPath = AssetDatabase.GUIDToAssetPath(shaderGuid);
lilToonInspector.RewriteShaderRP(shaderPath, lilRP);
}
lilToonInspector.RewriteShaderRP(lilToonInspector.shaderPipelinePath, lilRP);
lilToonSetting shaderSetting = (lilToonSetting)AssetDatabase.LoadAssetAtPath(lilToonInspector.shaderSettingPath, typeof(lilToonSetting));
lilToonInspector.RewriteShaderRP(shaderPipelinePath, lilRP);
lilToonSetting shaderSetting = (lilToonSetting)AssetDatabase.LoadAssetAtPath(shaderSettingPath, typeof(lilToonSetting));
if(shaderSetting != null) lilToonInspector.ApplyShaderSetting(shaderSetting);
lilToonInspector.ReimportPassShaders();
AssetDatabase.Refresh();
Expand Down Expand Up @@ -416,7 +419,7 @@ static void ConvertGifToAtlas()
}
}
atlasTexture.Apply();

// Save
string savePath = Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path) + "_gif2png_" + loopXY + "_" + frameCount + "_" + duration + ".png";
File.WriteAllBytes(savePath, atlasTexture.EncodeToPNG());
Expand Down Expand Up @@ -467,7 +470,7 @@ static void DotTextureReduction()
}
}
outTex.Apply();

// Save
string savePath = Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path) + "_resized" + ".png";
File.WriteAllBytes(savePath, outTex.EncodeToPNG());
Expand Down
2 changes: 1 addition & 1 deletion Assets/lilToon/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ This is an experimental feature that smooths polygons when you get close to them
<br/>

## Shader Setting
Features turned off here will be removed from the shader. By turning off unused features, you can reduce the size of your avatar while also reducing the load. When you place an avatar in a world, you need to match the shader settings specified by the world creator because the same settings are applied to all avatars placed in the world.
Features turned off here will be removed from the shader. By turning off unused features, you can reduce the size of your avatar while also reducing the load.

<br/>

Expand Down
2 changes: 1 addition & 1 deletion Assets/lilToon/MANUAL_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
<br/>

## シェーダー設定
全マテリアル共通の設定です。ここでオフにした機能はシェーダーから除去されます。不要な機能をオフにすることでアバターの容量を削減しつつ、負荷も抑えることができます。アバターをワールドに設置する場合、「ワールドに配置されているアバター全てに共通の設定が適用される」ためワールド製作者の指定したシェーダー設定に合わせる必要があります。
全マテリアル共通の設定です。ここでオフにした機能はシェーダーから除去されます。不要な機能をオフにすることでアバターの容量を削減しつつ、負荷も抑えることができます。

<br/>

Expand Down
40 changes: 35 additions & 5 deletions Assets/lilToon/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# lilToon
Version 1.1.4a
Version 1.1.5

# Overview
This shader is developed for services using avatars (VRChat, etc.) and has the following features.
Expand Down Expand Up @@ -74,19 +74,40 @@ I recommend right-clicking on the material and running `lilToon/Remove unused pr
# Common Problems
- Material error has occurred.
→ Clicking `Assets/lilToon/Refresh Shaders` in the top menu bar may help.
- Cannot use alpha mask
→ Please check the following
- Check and apply the alpha mask in [Shader Setting](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL.md#shader-setting) in the Advanced settings.
- Set rendering mode to `Cutout` or `Transparent`
- Assign a texture to `Alpha Mask` in the Main Color menu
- Some functions seem to be missing.
→ If you want to add more features, change the [Shader Setting](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL.md#shader-setting) in the Advanced settings.
- UI is not displayed when selecting a material / There is an error in the editor
→ You may have a mix of older versions of lilToon. Delete the `lilToon` folder and then import unitypackage again.
- Different meshes have different lighting.
→ Right click on your avatar and select `[lilToon] Fix Lighting` to automatically fix this.
- The shadows on face are dirty.
→ You can specify a mask texture in `Mask & Strength` to partially remove shadows.
- Outline becomes dirty.
→ You can specify a mask texture in `Mask & Width` to partially remove outline or adjust the thickness.
- Shadows are weak in bright places.
`Environment Strength` value affects the strength of shadows in bright places.
- Different meshes have different lighting.
→ Right click on your avatar and select `[lilToon] Fix Lighting` to automatically fix this.
- Some functions seem to be missing.
→ If you want to add more features, change the [Shader Setting](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL.md#shader-setting) in the Advanced settings.
- I don't know which ones to turn on in shader settings.
→ The shader settings are automatically set by running `Assets/lilToon/Auto shader setting` from the top menu bar.

If you have any other problems and suspect a bug, please contact me on [Twitter](https://twitter.com/lil_xyzw), [GitHub](https://github.com/lilxyzw/lilToon), or [BOOTH](https://lilxyzw.booth.pm/).
Please refer to the following template when reporting a bug.
```
Bug:
Reproduction method:
# Optional
Unity version:
Shader setting:
VRChat World:
Screenshots:
Console logs:
```

# Recommended settings outside the shader
The following settings improve the problem of different brightness in one part of the model. Also, texture transparency artifacts are removed.
- Select the mesh from the Hierarchy, unify the `Root Bone`, `Bounds`, and `Anchor Override` settings, and turn off `Recieve Shadows`.
Expand All @@ -104,10 +125,19 @@ I'm referred to the shadow setting part.
- [MToon (Santarh)](https://github.com/Santarh/MToon) / [MIT LICENCE](https://github.com/Santarh/MToon/blob/master/LICENSE)
Comparing parameters when implementing `Convert to MToon (VRM)`
- [GTAvaCrypt (rygo6)](https://github.com/rygo6/GTAvaCrypt) / [MIT LICENCE](https://github.com/rygo6/GTAvaCrypt/blob/master/LICENSE)
- [Multi-channel signed distance field generator](https://github.com/Chlumsky/msdfgen) / [MIT LICENCE](https://github.com/Chlumsky/msdfgen/blob/master/LICENSE.txt)
- [Optimized inverse trigonometric function (seblagarde)](https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/)
- [視差オクルージョンマッピング(parallax occlution mapping) (コポコポ)](https://coposuke.hateblo.jp/entry/2019/01/20/043042)

# Change log
## v1.1.5
- Added `When in trouble...`
- Improved transparency processing
- Organize the UI
- Added on / off of Z-axis rotation cancellation of MatCap
- Fixed shader folder to be movable
- Fixed an issue where opaque materials would show alpha mask properties
- Fixed some translations
## v1.1.4a
- Fixed an issue where `Setup from FBX` did not work in Unity 2017.3 or earlier, Unity 2019.3 or later
## v1.1.4
Expand Down
44 changes: 37 additions & 7 deletions Assets/lilToon/README_JP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# lilToon
Version 1.1.4a
Version 1.1.5

# 概要
アバターを用いたサービス(VRChat等)向けに開発したシェーダーで以下のような特徴があります。
Expand Down Expand Up @@ -75,19 +75,40 @@ MIT Licenseで公開しています。同梱の`LICENSE`をご確認ください
# よくあるトラブル
- マテリアルエラーが発生した
→ 上部メニューバーの`Assets/lilToon/Refresh Shaders`をクリックすると改善される場合があります
- アルファマスクが使えない
→ 以下をご確認ください
- 詳細設定の一番下の[シェーダー設定](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL_JP.md#シェーダー設定)`アルファマスク`にチェックを入れて`Apply`されているか
- 透過モードが`カットアウト`もしくは`半透明`になっているか
- 基本色設定内のアルファマスクでテクスチャを割り当てているか
- 一部機能が存在しないように見える
→ 機能を追加したい場合は詳細設定の一番下の[シェーダー設定](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL_JP.md#シェーダー設定)を変更してください
- マテリアルを選択してもUIが表示されない・エディタにエラーがある
→ 古いバージョンのlilToonが混在している可能性があります。`lilToon`フォルダを削除してから再度インポートし直して下さい。
- 部位によって明るさが変わる
→ アバターを右クリックし`[lilToon] Fix Lighting`を選択することで自動で修正されます。
- 明るい場所で影が薄くなる
`環境光の強さ`の数値を下げると明るい場所でも影が強く出ます。
- 顔にかかる影が気になる
`マスクと強度`にマスクテクスチャを指定することで部分的に影を消すことができます。
- 輪郭線が汚くなる
`マスクと太さ`にマスクテクスチャを指定することで部分的に輪郭線を消したり太さを調整したりすることができます。
- 明るい場所で影が薄くなる
`環境光の強さ`の数値を下げると明るい場所でも影が強く出ます。
- 部位によって明るさが変わる
→ アバターを右クリックし`[lilToon] Fix Lighting`を選択することで自動で修正されます。
- 一部機能が存在しないように見える
→ 機能を追加したい場合は詳細設定の一番下のの[シェーダー設定](https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/MANUAL_JP.md#シェーダー設定)を変更してください
- シェーダー設定でどれをオンにすべきかわからない
→ 上部メニューバーから`Assets/lilToon/Auto shader setting`を実行することで自動でシェーダー設定が行えます。

これ以外でトラブルが発生し不具合であることが疑われる場合は[Twitter](https://twitter.com/lil_xyzw)[GitHub](https://github.com/lilxyzw/lilToon)[BOOTH](https://lilxyzw.booth.pm/)のいずれかにご連絡いただければ幸いです。
以下にテンプレートも用意させていただきましたのでバグ報告の際の参考にご活用下さい。
```
バグ:
再現方法:
# 可能であれば
Unityバージョン:
シェーダー設定:
VRChatのワールド:
スクリーンショット:
コンソールログ:
```

# シェーダー外のおすすめ設定
以下の設定で顔など一部分だけ明るさが違う現象を緩和できます。また、テクスチャの透過が綺麗になります。
- Projectから透過テクスチャを選択し、Inspectorから`Alpha Is Transparency`にチェックを入れる
Expand All @@ -104,10 +125,19 @@ MIT Licenseで公開しています。同梱の`LICENSE`をご確認ください
- [MToon (Santarh)](https://github.com/Santarh/MToon) / [MIT LICENCE](https://github.com/Santarh/MToon/blob/master/LICENSE)
`MToon(VRM)に変換`の実装時に各種パラメータの比較を行いました。
- [GTAvaCrypt (rygo6)](https://github.com/rygo6/GTAvaCrypt) - [MIT LICENCE](https://github.com/rygo6/GTAvaCrypt/blob/master/LICENSE)
- [Multi-channel signed distance field generator](https://github.com/Chlumsky/msdfgen) / [MIT LICENCE](https://github.com/Chlumsky/msdfgen/blob/master/LICENSE.txt)
- [Optimized inverse trigonometric function (seblagarde)](https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/)
- [視差オクルージョンマッピング(parallax occlution mapping) (コポコポ)](https://coposuke.hateblo.jp/entry/2019/01/20/043042)

# 変更履歴
## v1.1.5
- `困ったときは…`を追加
- 透過処理を改善
- UIを整理
- マットキャップのZ軸回転キャンセル機能のオンオフを追加
- フォルダを移動可能にしました
- 不透明マテリアルにアルファマスクのプロパティが存在していた点を修正
- 一部翻訳を修正
## v1.1.4a
- `Setup from FBX`がUnity2017.3以前、Unity2019.3以降で動かない問題の修正
## v1.1.4
Expand Down
2 changes: 1 addition & 1 deletion Assets/lilToon/Shader/Includes/lil_common.hlsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef LIL_COMMON_INCLUDED
#define LIL_COMMON_INCLUDED

#ifndef LIL_CUSTOM_SHADER
#if !defined(LIL_CUSTOM_SHADER) && !defined(LIL_LITE)
#include "../../../lilToonSetting/lil_setting.hlsl"
#endif
#include "Includes/lil_macro.hlsl"
Expand Down
Loading

0 comments on commit 6cecb05

Please sign in to comment.