Skip to content

Commit

Permalink
added a new default shader that is in the transparent queue
Browse files Browse the repository at this point in the history
  • Loading branch information
prime31 committed Nov 10, 2014
1 parent a262158 commit c8ff3f1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Assets/Plugins/TransitionKit/TransitionKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void initialize()

// create the Material
material = getOrAddComponent<MeshRenderer>().material;
material.shader = _transitionKitDelegate.shaderForTransition() ?? Shader.Find( "Unlit/Texture" );
material.shader = _transitionKitDelegate.shaderForTransition() ?? Shader.Find( "prime[31]/Transitions/Texture With Alpha" );
material.color = Color.white; // reset to fully white

// snapshot the main camera before proceeding
_instance.StartCoroutine( _instance.setupCameraAndTexture() );
Expand Down Expand Up @@ -229,8 +230,8 @@ public IEnumerator waitForLevelToLoad( int level )
while( Application.loadedLevel != level )
yield return null;
}


/// <summary>
/// the most common type of transition seems to be one that ticks progress from 0 - 1. This method takes care of that for you
/// if your transition needs to have a _Progress property ticked after the scene loads.
Expand All @@ -241,7 +242,7 @@ public IEnumerator tickProgressPropertyInMaterial( float duration, bool reverseD
{
var start = reverseDirection ? 1f : 0f;
var end = reverseDirection ? 0f : 1f;

var elapsed = 0f;
while( elapsed < duration )
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Plugins/TransitionKit/TransitionKitDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Prime31.TransitionKit
public interface TransitionKitDelegate
{
/// <summary>
/// if the transition needs a custom shader return it here otherwise return null which will use the Unlit/Texture shader
/// if the transition needs a custom shader return it here otherwise return null which will use the TextureWithAlpha shader
/// </summary>
/// <returns>The for transition.</returns>
Shader shaderForTransition();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Shader "prime[31]/Transitions/Texture With Alpha"
{
Properties
{
_MainTex( "Base (RGB)", 2D ) = "white" {}
_Color( "Color", Color ) = ( 1.0, 1.0, 1.0, 1.0 )
}

SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"


uniform sampler2D _MainTex;
uniform float _Progress;
uniform fixed4 _Color;


fixed4 frag( v2f_img i ):COLOR
{
return tex2D( _MainTex, i.uv ) * _Color;
}

ENDCG
}
}

FallBack off
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8ff3f1

Please sign in to comment.