From d880cf5df52a2ad19f275b8680ddb6ec97b20db7 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 25 Feb 2015 13:54:54 +0000 Subject: [PATCH] Added custom material for Portrait system #84 --- Assets/Fungus/Portrait/Resources.meta | 5 + .../Portrait/Resources/Crossfade.shader | 89 +++++++++++++++ .../Portrait/Resources/Crossfade.shader.meta | 8 ++ Assets/Fungus/Portrait/Resources/Portrait.mat | 103 ++++++++++++++++++ .../Portrait/Resources/Portrait.mat.meta | 4 + 5 files changed, 209 insertions(+) create mode 100644 Assets/Fungus/Portrait/Resources.meta create mode 100644 Assets/Fungus/Portrait/Resources/Crossfade.shader create mode 100644 Assets/Fungus/Portrait/Resources/Crossfade.shader.meta create mode 100644 Assets/Fungus/Portrait/Resources/Portrait.mat create mode 100644 Assets/Fungus/Portrait/Resources/Portrait.mat.meta diff --git a/Assets/Fungus/Portrait/Resources.meta b/Assets/Fungus/Portrait/Resources.meta new file mode 100644 index 00000000..bfac19e1 --- /dev/null +++ b/Assets/Fungus/Portrait/Resources.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: afac93db866671940819cd3ecaa302dc +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Fungus/Portrait/Resources/Crossfade.shader b/Assets/Fungus/Portrait/Resources/Crossfade.shader new file mode 100644 index 00000000..dec7658d --- /dev/null +++ b/Assets/Fungus/Portrait/Resources/Crossfade.shader @@ -0,0 +1,89 @@ +Shader "Custom/Cross Fade" +{ + Properties + { + [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} + _TexStart ("Start Texture ", 2D) = "white" {} + _TexEnd ("End Texture", 2D) = "white" {} + _Fade ("Fade", Range(0, 1)) = 0 + _Alpha ("Alpha", Range(0, 1)) = 1 + _Color ("Tint", Color) = (1,1,1,1) + [MaterialToggle] _FlipStart("Flip Start Texture", Float) = 0 + [MaterialToggle] _FlipEnd("Flip End Texture", Float) = 0 + } + + SubShader + { + Tags + { + "Queue" = "Transparent" + "IgnoreProjector"="True" + "RenderType" = "Transparent" + "PreviewType"="Plane" + "CanUseSpriteAtlas"="True" + "ForceNoShadowCasting"="True" + } + Cull Off + ZWrite Off + Blend One OneMinusSrcAlpha + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + #include "UnityCG.cginc" + + sampler2D _MainTex; + fixed4 _MainTex_ST; + sampler2D _TexStart; + fixed4 _TexStart_ST; + sampler2D _TexEnd; + fixed4 _TexEnd_ST; + float _Fade; + float _Alpha; + fixed4 _Color; + float _FlipStart; + float _FlipEnd; + + struct appdata_t + { + float4 vertex : POSITION; + float2 texcoord : TEXCOORD0; + fixed4 color : COLOR; + }; + + struct v2f + { + float4 vertex : POSITION; + float2 texcoord : TEXCOORD0; + fixed4 color : COLOR; + }; + + v2f vert(appdata_t IN) + { + v2f OUT; + OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex); + OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex); + OUT.color = IN.color * _Color; + return OUT; + } + + fixed4 frag (v2f i) : COLOR + { + float2 start_uv = float2( i.texcoord.x, i.texcoord.y ); + float2 end_uv = float2( i.texcoord.x, i.texcoord.y ); + if ( _FlipStart != 0 ) + start_uv = float2( 1.0 - i.texcoord.x, i.texcoord.y ); + if ( _FlipEnd != 0 ) + end_uv = float2( 1.0 - i.texcoord.x, i.texcoord.y ); + fixed4 texStart = tex2D(_TexStart, start_uv); + fixed4 texEnd = tex2D(_TexEnd, end_uv); + fixed4 crosstex = ( texStart * texStart.a * (1.0-_Fade) ) + ( texEnd * texEnd.a * _Fade ); + return (crosstex * i.color) * _Alpha; + } + ENDCG + } + } + Fallback off +} \ No newline at end of file diff --git a/Assets/Fungus/Portrait/Resources/Crossfade.shader.meta b/Assets/Fungus/Portrait/Resources/Crossfade.shader.meta new file mode 100644 index 00000000..eb32b083 --- /dev/null +++ b/Assets/Fungus/Portrait/Resources/Crossfade.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bd2a5da5a3c2e94b95241a053a21199 +ShaderImporter: + defaultTextures: + - _MainTex: {instanceID: 0} + - _Tex1: {instanceID: 0} + - _Tex2: {instanceID: 0} + userData: diff --git a/Assets/Fungus/Portrait/Resources/Portrait.mat b/Assets/Fungus/Portrait/Resources/Portrait.mat new file mode 100644 index 00000000..f602af47 --- /dev/null +++ b/Assets/Fungus/Portrait/Resources/Portrait.mat @@ -0,0 +1,103 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Portrait + m_Shader: {fileID: 4800000, guid: 0bd2a5da5a3c2e94b95241a053a21199, type: 3} + m_ShaderKeywords: [] + m_CustomRenderQueue: -1 + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 2800000, guid: c27113fd8a09c7c45a856e5d3c843c11, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _TexStart + second: + m_Texture: {fileID: 2800000, guid: bcd5b5f11de95ec4ba92005e4a404502, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _TexEnd + second: + m_Texture: {fileID: 2800000, guid: f20cadd42b0548a4d8d2cd5b36223312, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _Tex1 + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _Tex2 + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: PixelSnap + second: 0 + data: + first: + name: _Fade + second: 1 + data: + first: + name: _FlipStart + second: 0 + data: + first: + name: _FlipEnd + second: 0 + data: + first: + name: _Alpha + second: 1 + data: + first: + name: _flipStart + second: 0 + data: + first: + name: _flipEnd + second: 0 + data: + first: + name: _Opacity + second: 1 + m_Colors: + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} + data: + first: + name: _StartColor + second: {r: 1, g: 1, b: 1, a: 1} + data: + first: + name: _EndColor + second: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Fungus/Portrait/Resources/Portrait.mat.meta b/Assets/Fungus/Portrait/Resources/Portrait.mat.meta new file mode 100644 index 00000000..85418838 --- /dev/null +++ b/Assets/Fungus/Portrait/Resources/Portrait.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 84ea47f59517f4ac1815f552cc8d60bc +NativeFormatImporter: + userData: