Semi-working fade into warehouse by trigger press

This commit is contained in:
2016-05-19 00:35:30 +02:00
parent ce46120e5a
commit cdf40b852e
12 changed files with 140 additions and 39 deletions
+16 -1
View File
@@ -1,12 +1,21 @@
using UnityEngine;
using System.Collections;
using Valve.VR;
public class CameraFade : MonoBehaviour {
public RenderTexture BlendTextureLeft;
public RenderTexture BlendTextureRight;
private float alpha = 0.0F;
static Material blitMaterial;
// Use this for initialization
void Start () {
if (!blitMaterial) {
blitMaterial = new Material(Shader.Find("Custom/TransparencyBitch"));
}
}
// Update is called once per frame
@@ -16,6 +25,12 @@ public class CameraFade : MonoBehaviour {
}
void OnRenderImage(RenderTexture src, RenderTexture dest) {
blitMaterial.SetFloat("_Ratio", alpha);
if (SteamVR_Render.eye == EVREye.Eye_Left) {
blitMaterial.SetTexture("_BlendTex", BlendTextureLeft);
} else {
blitMaterial.SetTexture("_BlendTex", BlendTextureRight);
}
Graphics.Blit(src, dest, blitMaterial);
}
}
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 15863de937343d84e9dc21fc4dea787c
timeCreated: 1463604762
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bb6fbe54b99bc0e46bc79e09c5fa111d
timeCreated: 1463605078
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
+6 -1
View File
@@ -14,7 +14,7 @@ public class SteamVR_Editor : Editor
int bannerHeight = 150;
Texture logo;
SerializedProperty script, wireframe;
SerializedProperty script, wireframe, RightEyeRenderTexture, LeftEyeRenderTexture;
string GetResourcePath()
{
@@ -36,6 +36,9 @@ public class SteamVR_Editor : Editor
wireframe = serializedObject.FindProperty("wireframe");
RightEyeRenderTexture = serializedObject.FindProperty("RightEyeRenderTexture");
LeftEyeRenderTexture = serializedObject.FindProperty("LeftEyeRenderTexture");
foreach (SteamVR_Camera target in targets)
target.ForceLast();
}
@@ -105,6 +108,8 @@ public class SteamVR_Editor : Editor
EditorGUILayout.PropertyField(script);
EditorGUILayout.PropertyField(wireframe);
EditorGUILayout.PropertyField(LeftEyeRenderTexture);
EditorGUILayout.PropertyField(RightEyeRenderTexture);
serializedObject.ApplyModifiedProperties();
}
+43 -36
View File
@@ -28,6 +28,8 @@ public class SteamVR_Camera : MonoBehaviour
}
public bool wireframe = false;
public RenderTexture LeftEyeRenderTexture;
public RenderTexture RightEyeRenderTexture;
[SerializeField]
private SteamVR_CameraFlip flip;
@@ -229,8 +231,8 @@ public class SteamVR_Camera : MonoBehaviour
#else
if (this != components[components.Length - 1] || flip == null)
{
if (flip == null)
flip = gameObject.AddComponent<SteamVR_CameraFlip>();
//if (flip == null)
// flip = gameObject.AddComponent<SteamVR_CameraFlip>();
#endif
// Store off values to be restored on new instance
values = new Hashtable();
@@ -385,8 +387,8 @@ public class SteamVR_Camera : MonoBehaviour
void OnPreRender()
{
if (flip)
flip.enabled = (SteamVR_Render.Top() == this && SteamVR.instance.graphicsAPI == EGraphicsAPIConvention.API_DirectX);
//if (flip)
// flip.enabled = (SteamVR_Render.Top() == this && SteamVR.instance.graphicsAPI == EGraphicsAPIConvention.API_DirectX);
var headCam = head.GetComponent<Camera>();
if (headCam != null)
@@ -402,44 +404,49 @@ public class SteamVR_Camera : MonoBehaviour
GL.wireframe = false;
}
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if (SteamVR_Render.Top() == this)
{
int eventID;
if (SteamVR_Render.eye == EVREye.Eye_Left)
{
// Get gpu started on work early to avoid bubbles at the top of the frame.
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_Flush);
void OnRenderImage(RenderTexture src, RenderTexture dest) {
if (LeftEyeRenderTexture == null) {
//if (SteamVR_Render.Top() == this) {
int eventID;
if (SteamVR_Render.eye == EVREye.Eye_Left) {
// Get gpu started on work early to avoid bubbles at the top of the frame.
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_Flush);
eventID = SteamVR.Unity.k_nRenderEventID_SubmitL;
}
else
{
eventID = SteamVR.Unity.k_nRenderEventID_SubmitR;
}
eventID = SteamVR.Unity.k_nRenderEventID_SubmitL;
}
else {
eventID = SteamVR.Unity.k_nRenderEventID_SubmitR;
}
// Queue up a call on the render thread to Submit our render target to the compositor.
SteamVR_Utils.QueueEventOnRenderThread(eventID);
}
// Queue up a call on the render thread to Submit our render target to the compositor.
SteamVR_Utils.QueueEventOnRenderThread(eventID);
//}
} else {
if (SteamVR_Render.eye == EVREye.Eye_Right) {
Graphics.Blit(src, RightEyeRenderTexture);
}
else {
Graphics.Blit(src, LeftEyeRenderTexture);
}
}
Graphics.SetRenderTarget(dest);
SteamVR_Camera.blitMaterial.mainTexture = src;
//Graphics.SetRenderTarget(dest);
//SteamVR_Camera.blitMaterial.mainTexture = src;
GL.PushMatrix();
GL.LoadOrtho();
SteamVR_Camera.blitMaterial.SetPass(0);
GL.Begin(GL.QUADS);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0);
GL.End();
GL.PopMatrix();
//GL.PushMatrix();
//GL.LoadOrtho();
//SteamVR_Camera.blitMaterial.SetPass(0);
//GL.Begin(GL.QUADS);
//GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0);
//GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0);
//GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0);
//GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0);
//GL.End();
//GL.PopMatrix();
Graphics.SetRenderTarget(null);
}
//Graphics.SetRenderTarget(null);
}
#endregion
+1 -1
View File
@@ -261,7 +261,7 @@ public class SteamVR_PlayArea : MonoBehaviour
// No need to remain enabled at runtime.
// Anyone that wants to change properties at runtime
// should call BuildMesh themselves.
//enabled = false;
enabled = false;
// If we want the configured bounds of the user,
// we need to wait for tracking.
BIN
View File
Binary file not shown.
+47
View File
@@ -0,0 +1,47 @@
Shader "Custom/TransparencyBitch" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_BlendTex ("Overlay", 2D) = "white" {}
_Ratio ("Ratio", Float) = 0
}
CGINCLUDE
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _BlendTex;
uniform float _Ratio;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex = v.texcoord;
return o;
}
float4 frag(v2f i) : COLOR {
float4 color = tex2D(_MainTex, i.tex);
float4 color2 = tex2D(_BlendTex, i.tex);
return float4(color.rgb * (1 - _Ratio) + color2.rgb * (_Ratio), 1);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b34e75cfff6508b4db83d740a420b0e9
timeCreated: 1463603082
licenseType: Free
ShaderImporter:
defaultTextures:
- _MainTex: {instanceID: 0}
- _BlendTex: {fileID: 2800000, guid: 6a329c6c386d4994d8eb9a05534ed2fc, type: 3}
userData:
assetBundleName:
assetBundleVariant: