Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
- version change for the CAM update
- slight improvments to the Evaluator UI
  • Loading branch information
YP committed Mar 21, 2023
1 parent 6e458a2 commit 4d0d8be
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 49 deletions.
162 changes: 118 additions & 44 deletions Editor/AvatarEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Thry.AvatarHelpers {
public class AvatarEvaluator : EditorWindow
{
public const string VERSION = "1.2.4";
public const string VERSION = "1.3.0";

[MenuItem("Thry/Avatar/Evaluator")]
static void Init()
Expand Down Expand Up @@ -73,12 +73,7 @@ public enum Quality { Excellent, Good, Medium, Poor, VeryPoor }
const int LAYER_LIMIT_MEDIUM = 30;
const int LAYER_LIMIT_POOR = 45;

bool _isGUIInit = false;
void InitGUI()
{
if (_avatar != null) Evaluate();
_isGUIInit = true;
}
GUIContent refreshIcon;

//ui variables
GameObject _avatar;
Expand Down Expand Up @@ -116,6 +111,11 @@ void InitGUI()

string[] _emptyStates;

private void OnEnable() {
refreshIcon = EditorGUIUtility.IconContent("RotateTool On", "Recalculate");
if (_avatar != null) Evaluate();
}

private void OnGUI()
{
EditorGUILayout.Space();
Expand All @@ -124,13 +124,24 @@ private void OnGUI()
Application.OpenURL("https://twitter.com/thryrallo");
EditorGUILayout.Space();

if (!_isGUIInit) InitGUI();
EditorGUI.BeginChangeCheck();
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
_avatar = (GameObject)EditorGUILayout.ObjectField("Avatar Gameobject", _avatar, typeof(GameObject), true);
if (EditorGUI.EndChangeCheck() && _avatar != null)

EditorGUILayout.LabelField("Input", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
using (new EditorGUILayout.HorizontalScope())
{
Evaluate();
//GUILayout.Label("Avatar", GUILayout.Width(40));
GUI.enabled = _avatar != null;
if(GUILayout.Button(refreshIcon, GUILayout.Width(30), GUILayout.Height(30))) {
Evaluate();
}
GUI.enabled = true;

_avatar = (GameObject)EditorGUILayout.ObjectField(GUIContent.none, _avatar, typeof(GameObject), true, GUILayout.Height(30));
if (EditorGUI.EndChangeCheck() && _avatar != null) {
Evaluate();
}

}

if (_avatar == null)
Expand All @@ -149,7 +160,6 @@ private void OnGUI()

if (_avatar != null)
{
if (GUILayout.Button("Recalculate")) Evaluate();
if (_shadersWithGrabpass == null) Evaluate();
if (_skinendMeshesWithBlendshapes == null) Evaluate();
EditorGUILayout.Space();
Expand All @@ -164,54 +174,35 @@ private void OnGUI()
_grabpassFoldout = DrawSection(_grabpassQuality, "Grabpasses", _grabpassCount.ToString(), _grabpassFoldout);
if(_grabpassFoldout)
{
EditorGUILayout.HelpBox("Grabpasses are very expensive. They save your whole screen at a certain point in the rendering process to use it as a texture in the shader.", MessageType.None);
if (_grabpassCount > 0)
{
foreach (Shader s in _shadersWithGrabpass)
EditorGUILayout.ObjectField(s, typeof(Shader), false);
}
DrawGrabpassFoldout();
}
//Blendshapes
_blendshapeFoldout = DrawSection(_blendshapeQuality, "Blendshapes", _totalBlendshapeData.ToString(), _blendshapeFoldout);
if(_blendshapeFoldout)
{
EditorGUILayout.LabelField($"Blendshape verticies: {_totalBlendshapeVerticies}");
EditorGUILayout.LabelField($"Blendshape data (verticies * blendshapes): {_totalBlendshapeData}");

EditorGUILayout.HelpBox("The performance impact of Blendshapes grows linear with polygon count. A general consense is that above 32.000 polygones splitting your mesh will improve performance." +
" Click here for more information to blendshapes from the VRChat Documentation.", MessageType.None);
if(Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
Application.OpenURL("https://docs.vrchat.com/docs/avatar-optimizing-tips#-except-when-youre-using-shapekeys");
if (_skinendMeshesWithBlendshapes.Count() > 0 && _skinendMeshesWithBlendshapes.First().Item2 > 32000)
EditorGUILayout.HelpBox($"Consider splitting \"{_skinendMeshesWithBlendshapes.First().Item1.name}\" into multiple meshes where only one has blendshapes. " +
$"This will reduce the amount polygons actively affected by blendshapes.", MessageType.Error);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Skinned Mesh Renderer");
EditorGUILayout.LabelField("Affected Triangles");
EditorGUILayout.EndHorizontal();
foreach ((SkinnedMeshRenderer, int, int) mesh in _skinendMeshesWithBlendshapes)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(mesh.Item1, typeof(SkinnedMeshRenderer), true);
EditorGUILayout.LabelField($"=> {mesh.Item2} triangles.");
EditorGUILayout.EndHorizontal();
}
DrawBlendshapeFoldout();
}

// Any states
_anyStateFoldout = DrawSection(_anyStateTransitionsQuality, "Any State Transitions", _anyStateTransitions.ToString(), _anyStateFoldout);
if(_anyStateFoldout)
{
EditorGUILayout.HelpBox("For each any state transition the conditons are checked every frame. " +
"This makes them expensive compared to normal transitions and a large number of them can seriously impact the CPU usage. A healty limit is around 50 transitions.", MessageType.None);
using(new DetailsFoldout("For each any state transition the conditons are checked every frame. " +
"This makes them expensive compared to normal transitions and a large number of them can seriously impact the CPU usage. A healty limit is around 50 transitions."))
{

}
}

// Layer count
_layerCountFoldout = DrawSection(_layerCountQuality, "Layer Count", _layerCount.ToString(), _layerCountFoldout);
if(_layerCountFoldout)
{
EditorGUILayout.HelpBox("The more layers you have the more expensive the animator is to run. " +
"Animators are running on the CPU, so in a CPU limited game like VRC the smaller the layer count, the better.", MessageType.None);
using(new DetailsFoldout("The more layers you have the more expensive the animator is to run. " +
"Animators are running on the CPU, so in a CPU limited game like VRC the smaller the layer count, the better."))
{

}
}

EditorGUILayout.Space();
Expand Down Expand Up @@ -279,6 +270,89 @@ bool DrawSection(Quality quality, string header, string value, bool foldout)
return foldout;
}

class DetailsFoldout : GUI.Scope
{
public DetailsFoldout(string info)
{
GUILayout.BeginHorizontal();
GUILayout.Space(30);
GUILayout.BeginVertical();
if (string.IsNullOrWhiteSpace(info) == false)
EditorGUILayout.HelpBox(info, MessageType.Info);
EditorGUILayout.Space();
}

protected override void CloseScope()
{
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
}

class GUILayoutIndent : GUI.Scope
{
public GUILayoutIndent(int indent)
{
GUILayout.BeginHorizontal();
GUILayout.Space(indent * 15);
GUILayout.BeginVertical();
}

protected override void CloseScope()
{
GUILayout.EndHorizontal();
}
}

void DrawGrabpassFoldout()
{
using(new DetailsFoldout("Grabpasses are very expensive. They save your whole screen at a certain point in the rendering process to use it as a texture in the shader."))
{
if (_grabpassCount > 0)
{
foreach (Shader s in _shadersWithGrabpass)
EditorGUILayout.ObjectField(s, typeof(Shader), false);
}
}
}

void DrawBlendshapeFoldout()
{
using(new DetailsFoldout("The performance impact of Blendshapes grows linear with polygon count. A general consense is that above 32.000 polygones splitting your mesh will improve performance." +
" Click here for more information to blendshapes from the VRChat Documentation."))
{
if(Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
Application.OpenURL("https://docs.vrchat.com/docs/avatar-optimizing-tips#-except-when-youre-using-shapekeys");

EditorGUILayout.BeginHorizontal(GUI.skin.box);
EditorGUILayout.LabelField("Blendshape Triangles: ", _totalBlendshapeVerticies.ToString());
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal(GUI.skin.box);
EditorGUILayout.LabelField("Blendshape Data: ", _totalBlendshapeData.ToString());
EditorGUILayout.EndHorizontal();

EditorGUILayout.Space();

if (_skinendMeshesWithBlendshapes.Count() > 0 && _skinendMeshesWithBlendshapes.First().Item2 > 32000)
EditorGUILayout.HelpBox($"Consider splitting \"{_skinendMeshesWithBlendshapes.First().Item1.name}\" into multiple meshes where only one has blendshapes. " +
$"This will reduce the amount polygons actively affected by blendshapes.", MessageType.Error);

EditorGUILayout.Space();

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Skinned Mesh Renderer");
EditorGUILayout.LabelField("Affected Triangles");
EditorGUILayout.EndHorizontal();
foreach ((SkinnedMeshRenderer, int, int) mesh in _skinendMeshesWithBlendshapes)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(mesh.Item1, typeof(SkinnedMeshRenderer), true);
EditorGUILayout.LabelField($"=> {mesh.Item2} triangles.");
EditorGUILayout.EndHorizontal();
}
}
}

public static void DrawQualityIcon(Quality type)
{
GUI.DrawTexture(EditorGUILayout.GetControlRect(false, 16, GUILayout.Width(16), GUILayout.Height(16)),
Expand Down
2 changes: 0 additions & 2 deletions Editor/VRAM Check/TextureVRAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
#if VRC_SDK_VRCSDK3 && !UDON
#endif

namespace Thry.AvatarHelpers
{
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ Please use this to keep your VRAM usage down. High VRAM usage causes performance

## Installing with VPM (for VRChat Creator Companion)

1. Open a Command Prompt in Windows and run
1. Install the VRChat CLI. [Follow the instructions from the VRChat docs. Click here.](https://vcc.docs.vrchat.com/vpm/cli/#installation--updating)
2. Open a Command Prompt in Windows and run
```sh
vpm add repo https://thryrallo.github.io/VRC-Avatar-Performance-Tools
```
2. In Creator Compantion click "Manage Project". In the top right under "Selected Repos" check the Avatar Performance Tools listing
3. In Creator Compantion click "Manage Project". In the top right under "Selected Repos" check the Avatar Performance Tools listing

## Installing with UPM (Unity Package Manager)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "de.thryrallo.vrc.avatar-performance-tools",
"displayName": "Thry's Avatar Performance Tools",
"version": "1.2.4",
"version": "1.3.0",
"description": "Calculated and evaluates some avatar metric not currently taking into account by vrchats ranking system.\r\n\nMost prominently gives a breakdown over VRAM usage of different parts of the avatar.",
"gitDependencies": {},
"vpmDependencies": {},
Expand Down

0 comments on commit 4d0d8be

Please sign in to comment.