Skip to content

Commit 8239f4f

Browse files
committed
2.6.0b2 (sdk 1.12.5) - Beta release version
1 parent 533940d commit 8239f4f

File tree

8 files changed

+279
-56
lines changed

8 files changed

+279
-56
lines changed

Assets/SteamVR/Editor/SteamVR_AutoEnableVR.cs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using System.IO;
1010
using System.Collections.Generic;
1111
using System.Linq;
12+
using System;
13+
using System.Reflection;
1214

1315
namespace Valve.VR
1416
{
@@ -21,8 +23,9 @@ static SteamVR_AutoEnableVR()
2123
}
2224

2325
protected const string openVRString = "OpenVR";
24-
protected const string openVRPackageString = "com.unity.xr.openvr.standalone";
26+
protected const string unityOpenVRPackageString = "com.unity.xr.openvr.standalone";
2527
protected const string valveOpenVRPackageString = "com.valvesoftware.unity.openvr";
28+
protected const string valveOpenVRPackageStringOld = "com.valve.openvr";
2629
protected const string valveOpenVRGitURL = "https://github.com/ValveSoftware/steamvr_unity_plugin.git#UnityXRPlugin";
2730

2831
#if UNITY_2018_2_OR_NEWER
@@ -127,19 +130,29 @@ public static void Update()
127130
break;
128131
}
129132

130-
string packageName = openVRPackageString;
131-
#if OPENVR_XR_API
132-
UnityEditor.PackageManager.Client.Remove(openVRPackageString); //remove the old one or the dlls will clash
133+
string packageName = null;
134+
135+
#if OPENVR_XR_API || UNITY_2020_1_OR_NEWER || XR_MGMT
136+
if (listRequest.Result.Any(package => package.name == unityOpenVRPackageString))
137+
UnityEditor.PackageManager.Client.Remove(unityOpenVRPackageString); //remove the old one or the dlls will clash
138+
if (listRequest.Result.Any(package => package.name == valveOpenVRPackageStringOld))
139+
UnityEditor.PackageManager.Client.Remove(valveOpenVRPackageStringOld); //remove the old one or the dlls will clash
133140

134141
packageName = valveOpenVRPackageString;
135-
#elif UNITY_2020_1_OR_NEWER || XR_MGMT
136-
packageName = valveOpenVRGitURL;
142+
#else
143+
packageName = unityOpenVRPackageString;
137144
#endif
138145

139146
bool hasPackage = listRequest.Result.Any(package => package.name == packageName);
140147

141148
if (hasPackage == false)
142149
{
150+
if (packageName == valveOpenVRPackageString)
151+
{
152+
packageState = PackageStates.Installed; //mark it as installed here so the npm installer can take over
153+
StartAutoUpdater();
154+
}
155+
143156
//if we don't have the package - then install it
144157
addRequest = UnityEditor.PackageManager.Client.Add(packageName);
145158
packageState = PackageStates.WaitingForAdd;
@@ -205,7 +218,7 @@ public static void Update()
205218
packageState = PackageStates.Failed;
206219
break;
207220
}
208-
string packageName = openVRPackageString;
221+
string packageName = unityOpenVRPackageString;
209222
#if OPENVR_XR_API
210223
packageName = valveOpenVRPackageString;
211224
#endif
@@ -252,9 +265,27 @@ public static void Update()
252265
}
253266
}
254267
#else
255-
UnityEditor.EditorApplication.update -= Update;
268+
UnityEditor.EditorApplication.update -= Update;
256269
#endif
257270
}
258271
}
272+
private static void StartAutoUpdater()
273+
{
274+
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
275+
for (int assemblyIndex = 0; assemblyIndex < assemblies.Length; assemblyIndex++)
276+
{
277+
Assembly assembly = assemblies[assemblyIndex];
278+
Type type = assembly.GetType("Unity.XR.OpenVR.OpenVRAutoUpdater");
279+
if (type != null)
280+
{
281+
MethodInfo preinitMethodInfo = type.GetMethod("Start");
282+
if (preinitMethodInfo != null)
283+
{
284+
preinitMethodInfo.Invoke(null, null);
285+
return;
286+
}
287+
}
288+
}
289+
}
259290
}
260291
}

Assets/SteamVR/InteractionSystem/Hints/Shaders/ControllerButtonHints.shader

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Shader "Valve/VR/ControllerButtonHints"
1212
_Color( "Color", Color ) = ( 1, 1, 1, 1 )
1313
_SceneTint( "SceneTint", Color ) = ( 1, 1, 1, 1 )
1414
}
15+
1516
SubShader
1617
{
1718
Tags{ "Queue" = "Transparent+1" "RenderType" = "Transparent" }
@@ -32,13 +33,57 @@ Shader "Valve/VR/ControllerButtonHints"
3233
}
3334

3435
CGPROGRAM
35-
3636
#pragma vertex MainVS
3737
#pragma fragment MainPS
38-
38+
3939
// Includes -------------------------------------------------------------------------------------------------------------------------------------------------
4040
#include "UnityCG.cginc"
4141

42+
#if UNITY_VERSION >= 201810
43+
44+
// Structs --------------------------------------------------------------------------------------------------------------------------------------------------
45+
struct VertexInput
46+
{
47+
float4 vertex : POSITION;
48+
49+
UNITY_VERTEX_INPUT_INSTANCE_ID
50+
};
51+
52+
struct VertexOutput
53+
{
54+
float4 vertex : SV_POSITION;
55+
56+
UNITY_VERTEX_OUTPUT_STEREO
57+
};
58+
59+
// Globals --------------------------------------------------------------------------------------------------------------------------------------------------
60+
UNITY_INSTANCING_BUFFER_START( Props )
61+
UNITY_DEFINE_INSTANCED_PROP( float4, _SceneTint )
62+
UNITY_INSTANCING_BUFFER_END( Props )
63+
64+
65+
// MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
66+
VertexOutput MainVS( VertexInput i )
67+
{
68+
VertexOutput o;
69+
UNITY_SETUP_INSTANCE_ID( i );
70+
UNITY_INITIALIZE_OUTPUT( VertexOutput, o );
71+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
72+
73+
o.vertex = UnityObjectToClipPos(i.vertex);
74+
75+
return o;
76+
}
77+
78+
// MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
79+
float4 MainPS( VertexOutput i ) : SV_Target
80+
{
81+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( i );
82+
83+
return UNITY_ACCESS_INSTANCED_PROP( Props, _SceneTint.rgba );
84+
}
85+
#else
86+
4287
// Structs --------------------------------------------------------------------------------------------------------------------------------------------------
4388
struct VertexInput
4489
{
@@ -70,7 +115,7 @@ Shader "Valve/VR/ControllerButtonHints"
70115
{
71116
return _SceneTint.rgba;
72117
}
73-
118+
#endif
74119
ENDCG
75120
}
76121
Pass
@@ -85,10 +130,63 @@ Shader "Valve/VR/ControllerButtonHints"
85130

86131
#pragma vertex MainVS
87132
#pragma fragment MainPS
88-
133+
89134
// Includes -------------------------------------------------------------------------------------------------------------------------------------------------
90135
#include "UnityCG.cginc"
91136

137+
#if UNITY_VERSION >= 201810
138+
139+
// Structs --------------------------------------------------------------------------------------------------------------------------------------------------
140+
struct VertexInput
141+
{
142+
float4 vertex : POSITION;
143+
float2 uv : TEXCOORD0;
144+
145+
UNITY_VERTEX_INPUT_INSTANCE_ID
146+
};
147+
148+
struct VertexOutput
149+
{
150+
float2 uv : TEXCOORD0;
151+
float4 vertex : SV_POSITION;
152+
153+
UNITY_VERTEX_OUTPUT_STEREO
154+
};
155+
156+
// Globals --------------------------------------------------------------------------------------------------------------------------------------------------
157+
UNITY_INSTANCING_BUFFER_START( Props )
158+
UNITY_DEFINE_INSTANCED_PROP( sampler2D, _MainTex )
159+
UNITY_DEFINE_INSTANCED_PROP( float4, _MainTex_ST )
160+
UNITY_DEFINE_INSTANCED_PROP( float4, _Color )
161+
UNITY_INSTANCING_BUFFER_END( Props )
162+
163+
// MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
164+
VertexOutput MainVS( VertexInput i )
165+
{
166+
VertexOutput o;
167+
UNITY_SETUP_INSTANCE_ID( i );
168+
UNITY_INITIALIZE_OUTPUT( VertexOutput, o );
169+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
170+
171+
o.vertex = UnityObjectToClipPos(i.vertex);
172+
173+
o.uv = TRANSFORM_TEX( i.uv, UNITY_ACCESS_INSTANCED_PROP( Props, _MainTex ) );
174+
175+
return o;
176+
}
177+
178+
// MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
179+
float4 MainPS( VertexOutput i ) : SV_Target
180+
{
181+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( i );
182+
183+
float4 vColor;
184+
vColor.rgb = lerp( tex2D( UNITY_ACCESS_INSTANCED_PROP( Props, _MainTex ), i.uv).rgb, UNITY_ACCESS_INSTANCED_PROP( Props, _Color.rgb ), UNITY_ACCESS_INSTANCED_PROP( Props, _Color.a ) );
185+
vColor.a = UNITY_ACCESS_INSTANCED_PROP( Props, _Color.a );
186+
187+
return vColor.rgba;
188+
}
189+
#else
92190
// Structs --------------------------------------------------------------------------------------------------------------------------------------------------
93191
struct VertexInput
94192
{
@@ -130,6 +228,7 @@ Shader "Valve/VR/ControllerButtonHints"
130228

131229
return vColor.rgba;
132230
}
231+
#endif
133232

134233
ENDCG
135234
}

Assets/SteamVR/InteractionSystem/Samples/BuggyBuddy/Materials/LightCone.shader

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,27 @@ Shader "FX/LightCone" {
2323
#pragma fragment frag
2424
#pragma multi_compile_particles
2525

26+
#if UNITY_VERSION >= 201810
27+
#pragma multi_compile_instancing
28+
#endif
29+
2630
#include "UnityCG.cginc"
2731

28-
sampler2D _MainTex;
32+
sampler2D _MainTex;
2933
fixed4 _TintColor;
3034
uniform fixed _BWEffectOn;
35+
float _InvFade;
36+
half _Rim;
3137

3238
struct appdata_t {
3339
float4 vertex : POSITION;
3440
float3 normal : NORMAL;
3541
fixed4 color : COLOR;
3642
fixed4 viewDir : TEXCOORD0;
43+
44+
#if UNITY_VERSION >= 201810
45+
UNITY_VERTEX_INPUT_INSTANCE_ID
46+
#endif
3747
};
3848

3949
struct v2f {
@@ -44,12 +54,22 @@ Shader "FX/LightCone" {
4454
#endif
4555
float3 normal : NORMAL;
4656
float3 viewDir : TEXCOORD1;
57+
58+
#if UNITY_VERSION >= 201810
59+
UNITY_VERTEX_OUTPUT_STEREO //Insert
60+
#endif
4761
};
4862

4963

64+
#if UNITY_VERSION >= 201810
5065
v2f vert(appdata_t v)
51-
{
66+
{
5267
v2f o;
68+
69+
UNITY_SETUP_INSTANCE_ID(v); //Insert
70+
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
71+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
72+
5373
o.vertex = UnityObjectToClipPos(v.vertex);
5474
#ifdef SOFTPARTICLES_ON
5575
o.projPos = ComputeScreenPos(o.vertex);
@@ -62,9 +82,48 @@ Shader "FX/LightCone" {
6282
return o;
6383
}
6484

85+
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
86+
87+
88+
fixed4 frag(v2f i) : SV_Target
89+
{
90+
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); //Insert
91+
92+
#ifdef SOFTPARTICLES_ON
93+
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
94+
float partZ = i.projPos.z;
95+
float fade = 1 - saturate(_InvFade * (partZ - sceneZ));
96+
i.color.a *= fade;
97+
#endif
98+
99+
i.color = pow(i.color,3);
100+
101+
half rim = saturate(pow(saturate(abs(dot(i.viewDir, i.normal))),_Rim));
102+
103+
i.color.a *= rim;
104+
105+
fixed4 finalCol = 2.0f * i.color * _TintColor;
106+
fixed lum = Luminance(finalCol.xyz);
107+
return finalCol;
108+
}
109+
110+
#else
111+
65112
sampler2D_float _CameraDepthTexture;
66-
float _InvFade;
67-
half _Rim;
113+
v2f vert(appdata_t v)
114+
{
115+
v2f o;
116+
o.vertex = UnityObjectToClipPos(v.vertex);
117+
#ifdef SOFTPARTICLES_ON
118+
o.projPos = ComputeScreenPos(o.vertex);
119+
COMPUTE_EYEDEPTH(o.projPos.z);
120+
#endif
121+
o.color = v.color;
122+
o.normal = v.normal;
123+
o.viewDir = normalize(ObjSpaceViewDir(v.vertex));
124+
125+
return o;
126+
}
68127

69128
fixed4 frag(v2f i) : SV_Target
70129
{
@@ -85,6 +144,7 @@ Shader "FX/LightCone" {
85144
fixed lum = Luminance(finalCol.xyz);
86145
return finalCol;
87146
}
147+
#endif
88148
ENDCG
89149
}
90150
}

Assets/SteamVR/OpenVRAutoUpdater/Editor/OpenVRAutoUpdater.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if UNITY_EDITOR && (UNITY_2020_1_OR_NEWER || VALVE_UPDATE_FORCE)
1+
#if UNITY_EDITOR && (UNITY_2019_3_OR_NEWER || VALVE_UPDATE_FORCE)
22
using System.IO;
33
using System.Linq;
44
using Unity.XR.OpenVR.SimpleJSON;
@@ -60,10 +60,15 @@ private static double runningSeconds
6060

6161
static OpenVRAutoUpdater()
6262
{
63-
#if UNITY_2020_1_OR_NEWER || VALVE_UPDATE_FORCE
63+
#if UNITY_2020_1_OR_NEWER || VALVE_UPDATE_FORCE
64+
Start();
65+
#endif
66+
}
67+
68+
public static void Start()
69+
{
6470
EditorApplication.update -= Update;
6571
EditorApplication.update += Update;
66-
#endif
6772
}
6873

6974
/// <summary>

0 commit comments

Comments
 (0)