mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-13 19:48:03 +07:00
shaders to right place and right names
This commit is contained in:
9
Assets/FlashTools/Resources.meta
Normal file
9
Assets/FlashTools/Resources.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9474654e1d88c44f0a63c615fe3abdd3
|
||||
folderAsset: yes
|
||||
timeCreated: 1469719998
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,4 @@
|
||||
Shader "FlashTools/FlashMaskReset" {
|
||||
Shader "FlashTools/SwfDecrMask" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ Shader "FlashTools/FlashMaskReset" {
|
||||
}
|
||||
|
||||
ColorMask 0
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
Stencil {
|
||||
@@ -47,9 +47,20 @@ Shader "FlashTools/FlashMaskReset" {
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _AlphaTex;
|
||||
float _AlphaSplitEnabled;
|
||||
|
||||
fixed4 SampleSpriteTexture(float2 uv) {
|
||||
fixed4 color = tex2D(_MainTex, uv);
|
||||
#if UNITY_TEXTURE_ALPHASPLIT_ALLOWED
|
||||
if (_AlphaSplitEnabled)
|
||||
color.a = tex2D(_AlphaTex, uv).r;
|
||||
#endif //UNITY_TEXTURE_ALPHASPLIT_ALLOWED
|
||||
return color;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target {
|
||||
fixed4 c = tex2D(_MainTex, IN.uv);
|
||||
fixed4 c = SampleSpriteTexture(IN.uv);
|
||||
if ( c.a < 0.01 ) {
|
||||
discard;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Shader "FlashTools/FlashMask" {
|
||||
Shader "FlashTools/SwfIncrMask" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ Shader "FlashTools/FlashMask" {
|
||||
}
|
||||
|
||||
ColorMask 0
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
Stencil {
|
||||
@@ -47,9 +47,20 @@ Shader "FlashTools/FlashMask" {
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _AlphaTex;
|
||||
float _AlphaSplitEnabled;
|
||||
|
||||
fixed4 SampleSpriteTexture(float2 uv) {
|
||||
fixed4 color = tex2D(_MainTex, uv);
|
||||
#if UNITY_TEXTURE_ALPHASPLIT_ALLOWED
|
||||
if (_AlphaSplitEnabled)
|
||||
color.a = tex2D(_AlphaTex, uv).r;
|
||||
#endif //UNITY_TEXTURE_ALPHASPLIT_ALLOWED
|
||||
return color;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target {
|
||||
fixed4 c = tex2D(_MainTex, IN.uv);
|
||||
fixed4 c = SampleSpriteTexture(IN.uv);
|
||||
if ( c.a < 0.01 ) {
|
||||
discard;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Shader "FlashTools/FlashMasked" {
|
||||
Shader "FlashTools/SwfMasked" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
|
||||
[PerRendererData] _StencilID ("Stencil ID" , Int) = 0
|
||||
@@ -13,10 +13,10 @@ Shader "FlashTools/FlashMasked" {
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
Stencil {
|
||||
@@ -1,4 +1,4 @@
|
||||
Shader "FlashTools/FlashAnim" {
|
||||
Shader "FlashTools/SwfSimple" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ Shader "FlashTools/FlashAnim" {
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
@@ -17,16 +17,10 @@ namespace FlashTools {
|
||||
float _frame_timer = 0.0f;
|
||||
string _last_asset_path = string.Empty;
|
||||
|
||||
List<Vector2> _uvs = new List<Vector2>();
|
||||
List<Color> _mulcolors = new List<Color>();
|
||||
List<Vector4> _addcolors = new List<Vector4>();
|
||||
List<Vector3> _vertices = new List<Vector3>();
|
||||
|
||||
enum GroupType {
|
||||
Mask,
|
||||
Group,
|
||||
MaskReset
|
||||
}
|
||||
List<Vector2> _uvs = new List<Vector2>();
|
||||
List<Color> _mulcolors = new List<Color>();
|
||||
List<Vector4> _addcolors = new List<Vector4>();
|
||||
List<Vector3> _vertices = new List<Vector3>();
|
||||
|
||||
class Group {
|
||||
public SwfAnimationInstanceType Type;
|
||||
@@ -149,73 +143,6 @@ namespace FlashTools {
|
||||
_groups.Add(gr);
|
||||
}
|
||||
|
||||
/*
|
||||
if ( inst.MaskGroup != 0 ) {
|
||||
if ( _groups.Count == 0 || _groups[_groups.Count - 1].MaskGroup != inst.MaskGroup ) {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Mask;
|
||||
gr.MaskGroup = inst.MaskGroup;
|
||||
gr.Triangles = new List<int>();
|
||||
_groups.Add(gr);
|
||||
} else {
|
||||
// batching mask group
|
||||
}
|
||||
} else {
|
||||
if ( _groups.Count == 0 ) {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Group;
|
||||
gr.MaskGroup = 0;
|
||||
gr.Triangles = new List<int>();
|
||||
_groups.Add(gr);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
if ( inst.ClipDepth != 0 ) {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Mask;
|
||||
gr.Triangles = new List<int>();
|
||||
gr.ClipDepth = inst.ClipDepth;
|
||||
_groups.Add(gr);
|
||||
} else {
|
||||
if ( _groups.Count == 0 ) {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Group;
|
||||
gr.Triangles = new List<int>();
|
||||
gr.ClipDepth = 0;
|
||||
_groups.Add(gr);
|
||||
} else {
|
||||
var last_group = _groups[_groups.Count - 1];
|
||||
if ( last_group.Type == GroupType.Mask ) {
|
||||
if ( inst.Depth <= last_group.ClipDepth ) {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Masked;
|
||||
gr.Triangles = new List<int>();
|
||||
gr.ClipDepth = last_group.ClipDepth;
|
||||
_groups.Add(gr);
|
||||
} else {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Group;
|
||||
gr.Triangles = new List<int>();
|
||||
gr.ClipDepth = 0;
|
||||
_groups.Add(gr);
|
||||
}
|
||||
} else if ( last_group.Type == GroupType.Masked ) {
|
||||
if ( inst.Depth <= last_group.ClipDepth ) {
|
||||
// nothing
|
||||
} else {
|
||||
var gr = new Group();
|
||||
gr.Type = GroupType.Group;
|
||||
gr.Triangles = new List<int>();
|
||||
gr.ClipDepth = 0;
|
||||
_groups.Add(gr);
|
||||
}
|
||||
} else if ( last_group.Type == GroupType.Group ) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
_groups[_groups.Count - 1].Triangles.Add(_vertices.Count - 4 + 2);
|
||||
_groups[_groups.Count - 1].Triangles.Add(_vertices.Count - 4 + 1);
|
||||
_groups[_groups.Count - 1].Triangles.Add(_vertices.Count - 4 + 0);
|
||||
@@ -230,20 +157,20 @@ namespace FlashTools {
|
||||
var gr = full_groups[i];
|
||||
switch ( gr.Type ) {
|
||||
case SwfAnimationInstanceType.Mask:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashMask"));
|
||||
gr.Material = new Material(Shader.Find("FlashTools/SwfIncrMask"));
|
||||
gr.Material.SetTexture("_MainTex", Asset.Atlas);
|
||||
break;
|
||||
case SwfAnimationInstanceType.Group:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashAnim"));
|
||||
gr.Material = new Material(Shader.Find("FlashTools/SwfSimple"));
|
||||
gr.Material.SetTexture("_MainTex", Asset.Atlas);
|
||||
break;
|
||||
case SwfAnimationInstanceType.Masked:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashMasked"));
|
||||
gr.Material = new Material(Shader.Find("FlashTools/SwfMasked"));
|
||||
gr.Material.SetTexture("_MainTex", Asset.Atlas);
|
||||
gr.Material.SetInt("_StencilID", gr.ClipDepth);
|
||||
break;
|
||||
case SwfAnimationInstanceType.MaskReset:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashMaskReset"));
|
||||
gr.Material = new Material(Shader.Find("FlashTools/SwfDecrMask"));
|
||||
gr.Material.SetTexture("_MainTex", Asset.Atlas);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user