remove color mode

This commit is contained in:
2016-10-01 03:09:12 +07:00
parent 874fc29375
commit 37230465b7
8 changed files with 36 additions and 88 deletions

View File

@@ -4,10 +4,9 @@ Shader "FlashTools/SwfMaskedGrab" {
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
_StencilID ("Stencil ID", Int) = 0
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode )] _SrcBlend ("SrcBlend" , Int) = 1
[Enum(UnityEngine.Rendering.BlendMode )] _DstBlend ("DstBlend" , Int) = 10
[Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorMask("ColorMask", Int) = 15
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("DstBlend", Int) = 10
}
SubShader {
@@ -19,10 +18,9 @@ Shader "FlashTools/SwfMaskedGrab" {
"CanUseSpriteAtlas" = "True"
}
Cull Off
Lighting Off
ZWrite Off
ColorMask [_ColorMask]
Cull Off
Lighting Off
ZWrite Off
BlendOp [_BlendOp]
Blend [_SrcBlend] [_DstBlend]

View File

@@ -4,10 +4,9 @@ Shader "FlashTools/SwfMasked" {
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
_StencilID ("Stencil ID", Int) = 0
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode )] _SrcBlend ("SrcBlend" , Int) = 1
[Enum(UnityEngine.Rendering.BlendMode )] _DstBlend ("DstBlend" , Int) = 10
[Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorMask("ColorMask", Int) = 15
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("DstBlend", Int) = 10
}
SubShader {
@@ -19,10 +18,9 @@ Shader "FlashTools/SwfMasked" {
"CanUseSpriteAtlas" = "True"
}
Cull Off
Lighting Off
ZWrite Off
ColorMask [_ColorMask]
Cull Off
Lighting Off
ZWrite Off
BlendOp [_BlendOp]
Blend [_SrcBlend] [_DstBlend]

View File

@@ -3,10 +3,9 @@ Shader "FlashTools/SwfSimpleGrab" {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode )] _SrcBlend ("SrcBlend" , Int) = 1
[Enum(UnityEngine.Rendering.BlendMode )] _DstBlend ("DstBlend" , Int) = 10
[Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorMask("ColorMask", Int) = 15
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("DstBlend", Int) = 10
}
SubShader {
@@ -18,10 +17,9 @@ Shader "FlashTools/SwfSimpleGrab" {
"CanUseSpriteAtlas" = "True"
}
Cull Off
Lighting Off
ZWrite Off
ColorMask [_ColorMask]
Cull Off
Lighting Off
ZWrite Off
BlendOp [_BlendOp]
Blend [_SrcBlend] [_DstBlend]

View File

@@ -3,10 +3,9 @@ Shader "FlashTools/SwfSimple" {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode )] _SrcBlend ("SrcBlend" , Int) = 1
[Enum(UnityEngine.Rendering.BlendMode )] _DstBlend ("DstBlend" , Int) = 10
[Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorMask("ColorMask", Int) = 15
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("DstBlend", Int) = 10
}
SubShader {
@@ -18,10 +17,9 @@ Shader "FlashTools/SwfSimple" {
"CanUseSpriteAtlas" = "True"
}
Cull Off
Lighting Off
ZWrite Off
ColorMask [_ColorMask]
Cull Off
Lighting Off
ZWrite Off
BlendOp [_BlendOp]
Blend [_SrcBlend] [_DstBlend]

View File

@@ -314,7 +314,6 @@ namespace FlashTools.Internal {
class BakedGroup {
public SwfInstanceData.Types Type;
public SwfColorModeData.Types ColorMode;
public SwfBlendModeData.Types BlendMode;
public int ClipDepth;
public int StartVertex;
@@ -376,13 +375,11 @@ namespace FlashTools.Internal {
if ( baked_groups.Count == 0 ||
baked_groups[baked_groups.Count - 1].Type != inst.Type ||
baked_groups[baked_groups.Count - 1].ColorMode != inst.ColorMode.type ||
baked_groups[baked_groups.Count - 1].BlendMode != inst.BlendMode.type ||
baked_groups[baked_groups.Count - 1].ClipDepth != inst.ClipDepth )
{
baked_groups.Add(new BakedGroup{
Type = inst.Type,
ColorMode = inst.ColorMode.type,
BlendMode = inst.BlendMode.type,
ClipDepth = inst.ClipDepth,
StartVertex = baked_vertices.Count - 4,
@@ -403,10 +400,10 @@ namespace FlashTools.Internal {
group.Material = settings_holder.GetIncrMaskMaterial();
break;
case SwfInstanceData.Types.Group:
group.Material = settings_holder.GetSimpleMaterial(group.ColorMode, group.BlendMode);
group.Material = settings_holder.GetSimpleMaterial(group.BlendMode);
break;
case SwfInstanceData.Types.Masked:
group.Material = settings_holder.GetMaskedMaterial(group.ColorMode, group.BlendMode, group.ClipDepth);
group.Material = settings_holder.GetMaskedMaterial(group.BlendMode, group.ClipDepth);
break;
case SwfInstanceData.Types.MaskReset:
group.Material = settings_holder.GetDecrMaskMaterial();

View File

@@ -194,7 +194,6 @@ namespace FlashTools.Internal {
ClipDepth = (ushort)frame_inst_clip_depth,
Bitmap = bitmap_id,
Matrix = SwfMatrixData.FromUMatrix(inst_matrix * bitmap_matrix.ToUMatrix()),
ColorMode = SwfColorModeData.identity,
BlendMode = inst_blend_mode,
ColorTrans = inst_color_transform});
if ( parent_mask > 0 ) {
@@ -254,7 +253,6 @@ namespace FlashTools.Internal {
ClipDepth = 0,
Bitmap = mask.Bitmap,
Matrix = mask.Matrix,
ColorMode = mask.ColorMode,
BlendMode = mask.BlendMode,
ColorTrans = mask.ColorTrans});
}

View File

@@ -99,14 +99,11 @@ namespace FlashTools.Internal {
}
void PregenerateMaterials() {
var color_modes = System.Enum.GetValues(typeof(SwfColorModeData.Types));
var blend_modes = System.Enum.GetValues(typeof(SwfBlendModeData.Types));
foreach ( SwfColorModeData.Types color_mode in color_modes ) {
foreach ( SwfBlendModeData.Types blend_mode in blend_modes ) {
GetSimpleMaterial(color_mode, blend_mode);
for ( var i = 0; i < 10; ++i ) {
GetMaskedMaterial(color_mode, blend_mode, i);
}
foreach ( SwfBlendModeData.Types blend_mode in blend_modes ) {
GetSimpleMaterial(blend_mode);
for ( var i = 0; i < 10; ++i ) {
GetMaskedMaterial(blend_mode, i);
}
}
GetIncrMaskMaterial();
@@ -198,22 +195,9 @@ namespace FlashTools.Internal {
static Material FillMaterial(
Material material,
SwfColorModeData.Types color_mode,
SwfBlendModeData.Types blend_mode,
int stencil_id)
{
switch ( color_mode ) {
case SwfColorModeData.Types.RGBA:
material.SetInt("_ColorMask", (int)ColorWriteMask.All);
break;
case SwfColorModeData.Types.A:
material.SetInt("_ColorMask", (int)ColorWriteMask.Alpha);
break;
default:
throw new UnityException(string.Format(
"SwfSettings. Incorrect color mode: {0}",
color_mode));
}
switch ( blend_mode ) {
case SwfBlendModeData.Types.Normal:
material.SetInt("_BlendOp" , (int)BlendOp.Add);
@@ -296,21 +280,19 @@ namespace FlashTools.Internal {
// ---------------------------------------------------------------------
public Material GetSimpleMaterial(
SwfColorModeData.Types color_mode,
SwfBlendModeData.Types blend_mode)
{
return LoadOrCreateMaterial(
CheckAndGetShader(SelectShader(false, blend_mode)),
(dir_path, filename) => {
return string.Format(
"{0}/{1}_{2}_{3}.mat",
dir_path, filename, color_mode, blend_mode);
"{0}/{1}_{2}.mat",
dir_path, filename, blend_mode);
},
material => FillMaterial(material, color_mode, blend_mode, 0));
material => FillMaterial(material, blend_mode, 0));
}
public Material GetMaskedMaterial(
SwfColorModeData.Types color_mode,
SwfBlendModeData.Types blend_mode,
int stencil_id)
{
@@ -318,10 +300,10 @@ namespace FlashTools.Internal {
CheckAndGetShader(SelectShader(true, blend_mode)),
(dir_path, filename) => {
return string.Format(
"{0}/{1}_{2}_{3}_{4}.mat",
dir_path, filename, color_mode, blend_mode, stencil_id);
"{0}/{1}_{2}_{3}.mat",
dir_path, filename, blend_mode, stencil_id);
},
material => FillMaterial(material, color_mode, blend_mode, stencil_id));
material => FillMaterial(material, blend_mode, stencil_id));
}
public Material GetIncrMaskMaterial() {

View File

@@ -105,26 +105,6 @@ namespace FlashTools {
}
}
[System.Serializable]
public struct SwfColorModeData {
public enum Types : byte {
RGBA,
A
}
public Types type;
public SwfColorModeData(Types type) {
this.type = type;
}
public static SwfColorModeData identity {
get {
return new SwfColorModeData{
type = Types.RGBA};
}
}
}
[System.Serializable]
public struct SwfBlendModeData {
public enum Types : byte {
@@ -211,7 +191,6 @@ namespace FlashTools {
public ushort ClipDepth = 0;
public ushort Bitmap = 0;
public SwfMatrixData Matrix = SwfMatrixData.identity;
public SwfColorModeData ColorMode = SwfColorModeData.identity;
public SwfBlendModeData BlendMode = SwfBlendModeData.identity;
public SwfColorTransData ColorTrans = SwfColorTransData.identity;
}