using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
public class PastOrFuture : MonoBehaviour
{
public Camera _activeCamera;
public Camera _hiddenCamera;
public MeshRenderer Mirror;
public int playerLayer;
public int activeLayer;
public int hiddenLayer;
private void Awake()
{
var rt = new RenderTexture(Screen.width, Screen.height, 24);
Mirror.material.SetTexture("_TimeCrackTexture", rt);
_hiddenCamera.targetTexture = rt;
Physics.IgnoreLayerCollision(playerLayer, activeLayer, false);
Physics.IgnoreLayerCollision(playerLayer, hiddenLayer, true);
SceneManager.LoadScene("Past", LoadSceneMode.Additive);
}
public void SwapScene()
{
_activeCamera.targetTexture = _hiddenCamera.targetTexture;
_hiddenCamera.targetTexture = null;
var swapCamera = _activeCamera;
_activeCamera = _hiddenCamera;
_hiddenCamera = swapCamera;
int layer = activeLayer;
activeLayer = hiddenLayer;
hiddenLayer = layer;
Physics.IgnoreLayerCollision(playerLayer, activeLayer, false);
Physics.IgnoreLayerCollision(playerLayer, hiddenLayer, true);
}
}
Shader "LSQ/EffectAchievement/PastOrFuture"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityStandardUtils.cginc"
struct VertIn
{
float4 vertex : POSITION;
};
struct FragIn
{
float4 vertex : SV_POSITION;
float4 screen_GrabUV : TEXCOORD1;
float3 screen_uv : TEXCOORD2;
};
FragIn vert (VertIn v)
{
FragIn o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.screen_GrabUV = ComputeGrabScreenPos(o.vertex);
return o;
}
sampler2D _TimeCrackTexture;
fixed4 frag (FragIn i) : SV_Target
{
fixed4 col = tex2Dproj(_TimeCrackTexture, UNITY_PROJ_COORD(i.screen_GrabUV));
return col;
}
ENDCG
}
}
}
|