Skip to content

Commit 07938ca

Browse files
Visual Profiler v2.0.0 (microsoft#11)
* Improved visual profiler.
1 parent ad16f8f commit 07938ca

17 files changed

Lines changed: 1332 additions & 843 deletions
File renamed without changes.

Data/Font.png

5.34 KB
Loading

Data/Font.png.meta

Lines changed: 144 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data/VisualProfiler.mat

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: VisualProfiler
11+
m_Shader: {fileID: 4800000, guid: 59811c61128561c4aa91d25965b11afb, type: 3}
12+
m_ShaderKeywords:
13+
m_LightmapFlags: 4
14+
m_EnableInstancingVariants: 1
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: 5000
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _FontTexture:
23+
m_Texture: {fileID: 2800000, guid: 238d3109a0d14c647b77f334fd2fe5ec, type: 3}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
m_Floats: []
27+
m_Colors:
28+
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
29+
- _Color: {r: 1, g: 1, b: 1, a: 1}
30+
m_BuildTextureStacks: []

Data/VisualProfiler.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data/VisualProfiler.shader

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
Shader "Hidden/Visual Profiler"
5+
{
6+
Properties
7+
{
8+
[MainColor] _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0)
9+
_BaseColor("Base Color", Color) = (0.0, 0.0, 0.0, 1.0)
10+
[MainTexture] _FontTexture("Font", 2D) = "black" {}
11+
}
12+
13+
SubShader
14+
{
15+
Pass
16+
{
17+
Name "Main"
18+
Tags{ "RenderType" = "Opaque" }
19+
Blend Off
20+
ZWrite On
21+
ZTest Always
22+
Cull Off
23+
24+
CGPROGRAM
25+
26+
#pragma vertex vert
27+
#pragma fragment frag
28+
29+
// Comment in to help with RenderDoc debugging.
30+
//#pragma enable_d3d11_debug_symbols
31+
32+
#pragma multi_compile_instancing
33+
34+
#include "UnityCG.cginc"
35+
36+
struct appdata_t
37+
{
38+
float4 vertex : POSITION;
39+
float2 uv : TEXCOORD0;
40+
UNITY_VERTEX_INPUT_INSTANCE_ID
41+
};
42+
43+
struct v2f
44+
{
45+
float4 vertex : SV_POSITION;
46+
fixed3 color : COLOR0;
47+
fixed3 baseColor : COLOR1;
48+
float2 uv : TEXCOORD0;
49+
UNITY_VERTEX_OUTPUT_STEREO
50+
};
51+
52+
fixed4 _BaseColor;
53+
sampler2D _FontTexture;
54+
float2 _FontScale;
55+
float4x4 _WindowLocalToWorldMatrix;
56+
57+
UNITY_INSTANCING_BUFFER_START(Props)
58+
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
59+
UNITY_DEFINE_INSTANCED_PROP(float4, _UVOffsetScaleX)
60+
UNITY_INSTANCING_BUFFER_END(Props)
61+
62+
v2f vert(appdata_t v)
63+
{
64+
v2f o;
65+
UNITY_SETUP_INSTANCE_ID(v);
66+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
67+
68+
float4 uvOffsetScaleX = UNITY_ACCESS_INSTANCED_PROP(Props, _UVOffsetScaleX);
69+
70+
// The verticies on the right (UV 1, x) are scaled in the positive X direction for progress bars.
71+
float3 localVertex = v.vertex.xyz;
72+
localVertex.x += v.uv.x * uvOffsetScaleX.z;
73+
74+
// Convert from window (local) to world space.
75+
// We do this in the vertex shader to avoid having to iterate over all instances each frame.
76+
o.vertex = mul(UNITY_MATRIX_VP, mul(_WindowLocalToWorldMatrix, mul(unity_ObjectToWorld, float4(localVertex, 1.0))));
77+
78+
// MaterialPropertyBlocks do not have a SetColorArray method, so we need to do color space conversions ourselves.
79+
#if defined(UNITY_COLORSPACE_GAMMA)
80+
o.color = UNITY_ACCESS_INSTANCED_PROP(Props, _Color).rgb;
81+
o.baseColor = _BaseColor.rgb;
82+
#else
83+
o.color = GammaToLinearSpace(UNITY_ACCESS_INSTANCED_PROP(Props, _Color).rgb);
84+
o.baseColor = GammaToLinearSpace(_BaseColor.rgb);
85+
#endif
86+
87+
// Scale and offset UVs.
88+
o.uv = (v.uv * _FontScale) + uvOffsetScaleX.xy;
89+
90+
return o;
91+
}
92+
93+
fixed4 frag(v2f i) : SV_Target
94+
{
95+
fixed4 font = tex2D(_FontTexture, i.uv);
96+
fixed alpha = font.r;
97+
return fixed4((i.baseColor * (1.0 - alpha)) + (font.rgb * i.color * alpha), 1.0);
98+
}
99+
100+
ENDCG
101+
}
102+
}
103+
}
8.56 KB
Loading
9.55 KB
Loading
18.5 KB
Loading

0 commit comments

Comments
 (0)