Skip to content

Commit f9dbbb8

Browse files
Merge pull request microsoft#5 from Cameron-Micka/holographicFramePresentationReport
Usability and Performance Improvements
2 parents 16375ec + 64c4f81 commit f9dbbb8

4 files changed

Lines changed: 378 additions & 145 deletions

File tree

-50.5 KB
Loading

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Missed frames are displayed over time to visually find problem areas. Memory is
88

99
The Visual Profiler is targeted towards profiling 3D UWP Unity applications, and has been verified to work on the following platforms:
1010

11-
- Microsoft HoloLens
11+
- Microsoft HoloLens & HoloLens 2
1212
- Microsoft Immersive headsets (IHMD)
1313
- Steam VR (HTC Vive / Oculus Rift)
1414
- OpenXR platforms
@@ -18,6 +18,8 @@ Clone, or download, VisualProfiler.cs and place it anywhere within the Assets fo
1818

1919
Next, add the VisualProfiler component to any gameobject in the Unity scene you wish to profile. The profiler is initially disabled (toggle-able via the initiallyActive property), but can be toggled via the enabled/disable voice command keywords.
2020

21+
NOTE: For improved rendering performance you can optionally include the "Hidden/Instanced-Colored" shader in your project along with the VisualProfiler.
22+
2123
IMPORTANT: Please make sure to add the microphone capability to your app if you plan on using the enable/disable keywords, in Unity under Edit -> Project Settings -> Player -> Settings for Windows Store -> Publishing Settings -> Capabilities or in your Visual Studio Package.appxmanifest capabilities.
2224

2325
## Usage

Shaders/InstancedColored.shader

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
Shader "Hidden/Instanced-Colored"
5+
{
6+
Properties
7+
{
8+
_Color("Color", Color) = (1.0, 1.0, 1.0, 1.0)
9+
_ZWrite("ZWrite", Int) = 1.0 // On
10+
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Int) = 4.0 // LEqual
11+
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Int) = 0.0 // Off
12+
}
13+
14+
SubShader
15+
{
16+
Pass
17+
{
18+
Name "Main"
19+
Tags{ "RenderType" = "Opaque" "PerformanceChecks" = "False" }
20+
ZWrite[_ZWrite]
21+
ZTest[_ZTest]
22+
Cull[_Cull]
23+
24+
CGPROGRAM
25+
26+
#if defined(SHADER_API_D3D11)
27+
#pragma target 5.0
28+
#endif
29+
30+
#pragma vertex vert
31+
#pragma fragment frag
32+
33+
#pragma multi_compile_instancing
34+
35+
#include "UnityCG.cginc"
36+
37+
struct appdata_t
38+
{
39+
fixed4 vertex : POSITION;
40+
UNITY_VERTEX_INPUT_INSTANCE_ID
41+
};
42+
43+
struct v2f
44+
{
45+
fixed4 vertex : SV_POSITION;
46+
fixed4 color : COLOR0;
47+
UNITY_VERTEX_OUTPUT_STEREO
48+
};
49+
50+
float4x4 _ParentLocalToWorldMatrix;
51+
52+
UNITY_INSTANCING_BUFFER_START(Props)
53+
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
54+
UNITY_INSTANCING_BUFFER_END(Props)
55+
56+
v2f vert(appdata_t v)
57+
{
58+
v2f o;
59+
UNITY_SETUP_INSTANCE_ID(v);
60+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
61+
o.vertex = mul(UNITY_MATRIX_VP, mul(_ParentLocalToWorldMatrix, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0))));
62+
o.color = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
63+
64+
return o;
65+
}
66+
67+
fixed4 frag(v2f i) : SV_Target
68+
{
69+
return i.color;
70+
}
71+
72+
ENDCG
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)