Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64bd045
commit dc0ace5
Showing
11 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class Blit : MonoBehaviour | ||
{ | ||
public Material _transitionMaterial; | ||
void OnRenderImage(RenderTexture source, RenderTexture dest) | ||
{ | ||
if (_transitionMaterial != null) | ||
{ | ||
Graphics.Blit(source, dest, _transitionMaterial); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Unity.VisualScripting; | ||
using UnityEngine; | ||
public class CameraTransition : MonoBehaviour | ||
{ | ||
[SerializeField] private Material _transitionMaterial; | ||
public Color TransitionColor; | ||
public static Action TransitionInDoneEvent; | ||
public static Action TransitionOutDoneEvent; | ||
public float timeForTransition; | ||
// public UnityEvent OnTransitionComplete; | ||
// public UityEvent OnTransitionStart; | ||
public bool OpenOnStart; | ||
private Blit _blit; | ||
private int _lerpID; | ||
private int _colorID; | ||
private Action afterTransitionAction; | ||
private void Awake() | ||
{ | ||
_lerpID = Shader.PropertyToID("_Lerp"); | ||
_colorID = Shader.PropertyToID("_Color"); | ||
_blit = gameObject.AddComponent<Blit>(); | ||
_blit._transitionMaterial = _transitionMaterial; | ||
_blit.enabled = false; | ||
|
||
if (OpenOnStart) | ||
{ | ||
_blit.enabled = true; | ||
TransitionOpenCurtain(); | ||
} | ||
} | ||
|
||
IEnumerator Transition(float start, float end, float totalTime) | ||
{ | ||
_blit.enabled = true; | ||
_transitionMaterial.SetFloat(_lerpID,start); | ||
_transitionMaterial.SetColor(_colorID,TransitionColor); | ||
float t = 0; | ||
while (t < 1) | ||
{ | ||
_transitionMaterial.SetFloat(_lerpID,Mathf.Lerp(start,end,t)); | ||
t += Time.deltaTime / totalTime; | ||
yield return null; | ||
} | ||
_transitionMaterial.SetFloat(_lerpID,end); | ||
yield return null; | ||
if (end == 0) | ||
{ | ||
_blit.enabled = false; | ||
TransitionOutDoneEvent?.Invoke(); | ||
}else if (end == 1) | ||
{ | ||
TransitionInDoneEvent?.Invoke(); | ||
} | ||
afterTransitionAction?.Invoke(); | ||
} | ||
|
||
[ContextMenu("Transition In")] | ||
public Coroutine TransitionCloseCurtain() | ||
{ | ||
afterTransitionAction = null; | ||
return StartCoroutine(Transition(0, 1, timeForTransition)); | ||
} | ||
[ContextMenu("Transition Out")] | ||
|
||
public Coroutine TransitionOpenCurtain() | ||
{ | ||
afterTransitionAction = null; | ||
return StartCoroutine(Transition(1, 0, timeForTransition)); | ||
} | ||
|
||
public void TransitionOpenCurtain(Action afterAction) | ||
{ | ||
afterTransitionAction = afterAction; | ||
StartCoroutine(Transition(1, 0, timeForTransition)); | ||
} | ||
public Coroutine TransitionCloseCurtain(Action afterAction) | ||
{ | ||
afterTransitionAction = afterAction; | ||
return StartCoroutine(Transition(0, 1, timeForTransition)); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!21 &2100000 | ||
Material: | ||
serializedVersion: 6 | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: TexTransition | ||
m_Shader: {fileID: 4800000, guid: 5add5d06b4d740e438ccac7f7ac74a3e, type: 3} | ||
m_ShaderKeywords: | ||
m_LightmapFlags: 4 | ||
m_EnableInstancingVariants: 0 | ||
m_DoubleSidedGI: 0 | ||
m_CustomRenderQueue: -1 | ||
stringTagMap: {} | ||
disabledShaderPasses: [] | ||
m_SavedProperties: | ||
serializedVersion: 3 | ||
m_TexEnvs: | ||
- _BumpMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _DetailAlbedoMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _DetailMask: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _DetailNormalMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _EmissionMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _MainTex: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _MetallicGlossMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _OcclusionMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _ParallaxMap: | ||
m_Texture: {fileID: 0} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
- _Transition: | ||
m_Texture: {fileID: 2800000, guid: 9423925000db1be4fa37a28badf0d122, type: 3} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
m_Ints: [] | ||
m_Floats: | ||
- _BumpScale: 1 | ||
- _Cutoff: 0.5 | ||
- _DetailNormalMapScale: 1 | ||
- _DstBlend: 0 | ||
- _GlossMapScale: 1 | ||
- _Glossiness: 0.5 | ||
- _GlossyReflections: 1 | ||
- _Lerp: 0 | ||
- _Metallic: 0 | ||
- _Mode: 0 | ||
- _OcclusionStrength: 1 | ||
- _Parallax: 0.02 | ||
- _Smooth: 0.233 | ||
- _SmoothnessTextureChannel: 0 | ||
- _SpecularHighlights: 1 | ||
- _SrcBlend: 1 | ||
- _UVSec: 0 | ||
- _ZWrite: 1 | ||
m_Colors: | ||
- _BackgroundColor: {r: 0, g: 0, b: 0, a: 1} | ||
- _Color: {r: 1, g: 1, b: 1, a: 1} | ||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} | ||
m_BuildTextureStacks: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Shader "Bloops/CameraUtility/TexTransition" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Texture", 2D) = "white" {} | ||
_Transition ("Transition",2D) = "white" {} | ||
_Color ("Color", Color) = (0, 0, 0, 1) | ||
_Lerp ("Lerp", Range(0, 1)) = 0 | ||
} | ||
SubShader | ||
{ | ||
// No culling or depth | ||
Cull Off ZWrite Off ZTest Always | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
}; | ||
|
||
v2f vert (appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.uv = v.uv; | ||
return o; | ||
} | ||
|
||
sampler2D _MainTex; | ||
sampler2D _Transition; | ||
float4 _Color; | ||
float _Lerp; | ||
float _Smooth; | ||
|
||
fixed4 frag (v2f i) : SV_Target | ||
{ | ||
if(_Lerp == 1) | ||
{ | ||
return _Color; | ||
} | ||
fixed4 col = tex2D(_MainTex,i.uv);; | ||
if(_Lerp == 0) | ||
{ | ||
return col; | ||
} | ||
fixed4 transition = tex2D(_Transition,i.uv); | ||
|
||
if (_Lerp >= transition.r) | ||
{ | ||
return _Color; | ||
} | ||
|
||
return col; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Shader "Bloops/CameraUtility/WipeTransition" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Texture", 2D) = "white" {} | ||
_Color ("Color", Color) = (0, 0, 0, 1) | ||
_Lerp ("Lerp", Range(0, 1)) = 0 | ||
} | ||
SubShader | ||
{ | ||
// No culling or depth | ||
Cull Off ZWrite Off ZTest Always | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
}; | ||
|
||
v2f vert (appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.uv = v.uv; | ||
return o; | ||
} | ||
|
||
sampler2D _MainTex; | ||
float4 _Color; | ||
float _Lerp; | ||
|
||
fixed4 frag (v2f i) : SV_Target | ||
{ | ||
//the uv x position is a nice 0->1 left to right | ||
fixed4 col = _Color; | ||
if(i.uv.x < 1-_Lerp) | ||
{ | ||
col = tex2D(_MainTex, i.uv); | ||
} | ||
|
||
return col; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
Oops, something went wrong.