mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
masks wip
This commit is contained in:
@@ -145,7 +145,7 @@ Camera:
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 5
|
||||
orthographic size: 3
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace FlashTools.Internal {
|
||||
return AddDisplayListToFrame(
|
||||
context,
|
||||
context.DisplayList,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
Matrix4x4.identity,
|
||||
@@ -83,7 +83,7 @@ namespace FlashTools.Internal {
|
||||
static SwfAnimationFrameData AddDisplayListToFrame(
|
||||
SwfContext ctx,
|
||||
SwfDisplayList dl,
|
||||
bool parent_masked,
|
||||
ushort parent_masked,
|
||||
ushort parent_mask,
|
||||
List<SwfAnimationInstanceData> parent_masks,
|
||||
Matrix4x4 parent_matrix,
|
||||
@@ -123,8 +123,8 @@ namespace FlashTools.Internal {
|
||||
var bitmap_def = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
if ( bitmap_def != null ) {
|
||||
frame.Instances.Add(new SwfAnimationInstanceData{
|
||||
Type = (parent_mask > 0 || inst.ClipDepth > 0) ? SwfAnimationInstanceType.Mask : (parent_masked || masks.Count > 0 ? SwfAnimationInstanceType.Masked : SwfAnimationInstanceType.Group),
|
||||
ClipDepth = (ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (ushort)0)),
|
||||
Type = (parent_mask > 0 || inst.ClipDepth > 0) ? SwfAnimationInstanceType.Mask : (parent_masked > 0 || masks.Count > 0 ? SwfAnimationInstanceType.Masked : SwfAnimationInstanceType.Group),
|
||||
ClipDepth = (ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (parent_masked + masks.Count))),
|
||||
Bitmap = bitmap_id,
|
||||
Matrix = parent_matrix * inst.Matrix.ToUnityMatrix() * bitmap_matrix.ToUnityMatrix(),
|
||||
ColorTransform = parent_color_transform * inst.ColorTransform.ToAnimationColorTransform()});
|
||||
@@ -149,7 +149,7 @@ namespace FlashTools.Internal {
|
||||
AddDisplayListToFrame(
|
||||
ctx,
|
||||
sprite_inst.DisplayList,
|
||||
parent_masked ? parent_masked : (masks.Count > 0),
|
||||
(ushort)(parent_masked + masks.Count),
|
||||
(ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (ushort)0)),
|
||||
parent_mask > 0 ? parent_masks : (inst.ClipDepth > 0 ? masks : null),
|
||||
parent_matrix * sprite_inst.Matrix.ToUnityMatrix(),
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace FlashTools {
|
||||
|
||||
class Group {
|
||||
public SwfAnimationInstanceType Type;
|
||||
public int ClipDepth;
|
||||
public List<int> Triangles;
|
||||
public Material Material;
|
||||
}
|
||||
@@ -140,9 +141,10 @@ namespace FlashTools {
|
||||
_addcolors.Add(inst.ColorTransform.Add);
|
||||
_addcolors.Add(inst.ColorTransform.Add);
|
||||
|
||||
if ( _groups.Count == 0 || _groups[_groups.Count - 1].Type != inst.Type) {
|
||||
if ( _groups.Count == 0 || _groups[_groups.Count - 1].Type != inst.Type || _groups[_groups.Count - 1].ClipDepth != inst.ClipDepth) {
|
||||
var gr = new Group();
|
||||
gr.Type = inst.Type;
|
||||
gr.ClipDepth = inst.ClipDepth;
|
||||
gr.Triangles = new List<int>();
|
||||
_groups.Add(gr);
|
||||
}
|
||||
@@ -238,6 +240,7 @@ namespace FlashTools {
|
||||
case SwfAnimationInstanceType.Masked:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashMasked"));
|
||||
gr.Material.SetTexture("_MainTex", Asset.Atlas);
|
||||
gr.Material.SetInt("_StencilID", gr.ClipDepth);
|
||||
break;
|
||||
case SwfAnimationInstanceType.MaskReset:
|
||||
gr.Material = new Material(Shader.Find("FlashTools/FlashMaskReset"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Shader "FlashTools/FlashMasked" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
|
||||
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
|
||||
[PerRendererData] _StencilID ("Stencil ID" , Int) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
@@ -19,8 +20,8 @@ Shader "FlashTools/FlashMasked" {
|
||||
|
||||
Pass {
|
||||
Stencil {
|
||||
Ref 0
|
||||
Comp Less
|
||||
Ref [_StencilID]
|
||||
Comp Equal
|
||||
}
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
|
||||
Reference in New Issue
Block a user