Skip to content

Commit

Permalink
Transparency by mask draft shader.
Browse files Browse the repository at this point in the history
  • Loading branch information
nubick committed Jun 14, 2016
1 parent 48513a9 commit d1fa1c1
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 1 deletion.
Binary file modified sources/Assets/Scenes/Shaders.unity
Binary file not shown.
Binary file modified sources/Assets/Scripts/Shaders/Grayscale.mat
Binary file not shown.
Binary file added sources/Assets/Scripts/Shaders/Transparency.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions sources/Assets/Scripts/Shaders/Transparency.mat.meta

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

82 changes: 82 additions & 0 deletions sources/Assets/Scripts/Shaders/Transparency.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Shader "Custom/Transparency"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_AlphaTex("Alpha Texture", 2D) = "white" {}
_Amount("Amount", Range(0,1)) = 1.0
_Amount2("Amount2", Range(0,1)) = 1.0
}

SubShader
{
Tags
{
"Queue"="Transparent"
//"Queue" = "Transparent+1"
"IgnoreProjector"="True"
//"RenderType" = "Opaque"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}

Cull Off
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};

struct v2f
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};

v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
return OUT;
}

sampler2D _MainTex;
sampler2D _AlphaTex;
float _Amount;
float _Amount2;

fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = tex2D(_MainTex, IN.texcoord);
c.rgb *= c.a;

fixed4 t = tex2D(_AlphaTex, IN.texcoord);


if (t.a < _Amount)
return fixed4(0, 0, 0, 0);
else
return c;

//return lerp(c, c*t.a, _Amount);

//return lerp(c, c*pow(t.a, 1 / _Amount2), _Amount);
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions sources/Assets/Scripts/Shaders/Transparency.shader.meta

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

Binary file added sources/Assets/Textures/appear2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions sources/Assets/Textures/appear2.png.meta

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

Binary file added sources/Assets/Textures/death_star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions sources/Assets/Textures/death_star.png.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions sources/Assets/Textures/death_star_transparency.png.meta

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

Binary file modified sources/ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file modified sources/ProjectSettings/ProjectSettings.asset
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 5.3.2f1
m_EditorVersion: 5.3.4f1
m_StandardAssetsVersion: 0

0 comments on commit d1fa1c1

Please sign in to comment.