1
0
mirror of synced 2024-11-30 18:24:39 +01:00

BFLYT : Improve saving (material flags and part panes)

This commit is contained in:
KillzXGaming 2020-02-03 17:17:49 -05:00
parent c01be70a71
commit d70fef1f9f
10 changed files with 61 additions and 47 deletions

View File

@ -1896,14 +1896,18 @@ namespace LayoutBXLYT.Cafe
writer.WriteString(LayoutFileName);
writer.Align(4);
for (int i = 0; i < Properties.Count; i++)
Properties[i].WritePaneInfo(writer, header, startPos);
for (int i = 0; i < Properties.Count; i++)
Properties[i].WriteUserData(writer, header, startPos);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteProperties(writer, header, startPos);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteUserData(writer, header, startPos);
for (int i = 0; i < Properties.Count; i++)
{
Properties[i].WriteProperties(writer, header, startPos);
Properties[i].WriteUserData(writer, header, startPos);
Properties[i].WritePaneInfo(writer, header, startPos);
}
}
}
@ -2548,12 +2552,6 @@ namespace LayoutBXLYT.Cafe
TextureTransforms = TextureTransforms.AddToArray(new TextureTransform());
}
[DisplayName("Thresholding Alpha Interpolation"), CategoryAttribute("Alpha")]
public override bool ThresholdingAlphaInterpolation
{
get { return Convert.ToBoolean((flags >> 18) & 0x1); }
}
[DisplayName("Black Color"), CategoryAttribute("Color")]
public override STColor8 BlackColor { get; set; }
@ -2652,7 +2650,10 @@ namespace LayoutBXLYT.Cafe
var hasIndParam = Convert.ToBoolean((flags >> 14) & 0x1);
var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);
var hasFontShadowParam = Convert.ToBoolean((flags >> 17) & 0x1);
AlphaInterpolation = Convert.ToBoolean((flags >> 18) & 0x1);
Console.WriteLine($"MAT1 {Name}");
Console.WriteLine($"texCount {texCount}");
Console.WriteLine($"mtxCount {mtxCount}");
Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
@ -2664,6 +2665,7 @@ namespace LayoutBXLYT.Cafe
Console.WriteLine($"hasIndParam {hasIndParam}");
Console.WriteLine($"projTexGenParamCount {projTexGenParamCount}");
Console.WriteLine($"hasFontShadowParam {hasFontShadowParam}");
Console.WriteLine($"AlphaInterpolation {AlphaInterpolation}");
EnableAlphaCompare = hasAlphaCompare;
EnableBlend = hasBlendMode;
@ -2750,7 +2752,6 @@ namespace LayoutBXLYT.Cafe
flags += Bit.BitInsert(1, 1, 2, 24);
((TevStage)TevStages[i]).Write(writer);
}
if (AlphaCompare != null && EnableAlphaCompare)
{
flags += Bit.BitInsert(1, 1, 1, 22);
@ -2784,8 +2785,10 @@ namespace LayoutBXLYT.Cafe
FontShadowParameter.Write(writer);
}
using (writer.TemporarySeek(flagPos, SeekOrigin.Begin))
{
if (AlphaInterpolation)
flags += Bit.BitInsert(1, 1, 1, 13);
using (writer.TemporarySeek(flagPos, SeekOrigin.Begin)) {
writer.Write(flags);
}
}

View File

@ -27,7 +27,7 @@ namespace LayoutBXLYT
SetInt("textures0", 0);
SetInt("textures1", 0);
SetInt("textures2", 0);
SetBool("ThresholdingAlphaInterpolation", false);
SetBool("AlphaInterpolation", false);
var rotationMatrix = Matrix4.Identity;
SetMatrix("rotationMatrix", ref rotationMatrix);
SetInt("numTevStages", 0);
@ -81,7 +81,7 @@ namespace LayoutBXLYT
shader.SetVec2("uvTranslate0", new Vector2(0, 0));
shader.SetInt("flipTexture", 0);
shader.SetInt("numTevStages", material.TevStages.Length);
shader.SetBool("ThresholdingAlphaInterpolation", material.ThresholdingAlphaInterpolation);
shader.SetBool("AlphaInterpolation", material.AlphaInterpolation);
shader.SetVec4("IndirectMat0", new Vector4(1, 1, 0, 0));
shader.SetVec4("IndirectMat1", new Vector4(1, 1, 0, 0));
shader.SetInt("tevTexMode", 0);

View File

@ -27,7 +27,7 @@ namespace LayoutBXLYT
SetInt("textures0", 0);
SetInt("textures1", 0);
SetInt("textures2", 0);
SetBool("ThresholdingAlphaInterpolation", false);
SetBool("AlphaInterpolation", false);
SetVec2("uvScale0", new Vector2(1, 1));
SetFloat("uvRotate0", 0);
@ -56,7 +56,7 @@ namespace LayoutBXLYT
shader.SetFloat("uvRotate0", 0);
shader.SetVec2("uvTranslate0", new Vector2(0, 0));
shader.SetInt("flipTexture", 0);
shader.SetBool("ThresholdingAlphaInterpolation", material.ThresholdingAlphaInterpolation);
shader.SetBool("AlphaInterpolation", material.AlphaInterpolation);
shader.SetInt($"texCoords0GenType", 0);
shader.SetInt($"texCoords0Source", 0);

View File

@ -2277,8 +2277,8 @@ namespace LayoutBXLYT
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytAlphaCompare AlphaCompare { get; set; }
[DisplayName("Thresholding Alpha Interpolation"), CategoryAttribute("Alpha")]
public virtual bool ThresholdingAlphaInterpolation { get; set; }
[DisplayName("Alpha Interpolation"), CategoryAttribute("Alpha")]
public virtual bool AlphaInterpolation { get; set; }
[DisplayName("Texture Maps"), CategoryAttribute("Texture")]
public BxlytTextureRef[] TextureMaps { get; set; }

View File

@ -27,7 +27,7 @@ namespace LayoutBXLYT
SetInt("textures0", 0);
SetInt("textures1", 0);
SetInt("textures2", 0);
SetBool("ThresholdingAlphaInterpolation", false);
SetBool("AlphaInterpolation", false);
var rotationMatrix = Matrix4.Identity;
SetMatrix("rotationMatrix", ref rotationMatrix);
SetInt("numTevStages", 0);
@ -102,7 +102,7 @@ namespace LayoutBXLYT
shader.SetVec2("uvTranslate0", new Vector2(0, 0));
shader.SetInt("flipTexture", 0);
shader.SetInt("numTevStages", 0);
shader.SetBool("ThresholdingAlphaInterpolation", material.ThresholdingAlphaInterpolation);
shader.SetBool("AlphaInterpolation", material.AlphaInterpolation);
shader.SetVec4("IndirectMat0", new Vector4(1, 1, 0, 0));
shader.SetVec4("IndirectMat1", new Vector4(1, 1, 0, 0));
shader.SetInt("tevTexMode", 0);

View File

@ -32,7 +32,7 @@ namespace LayoutBXLYT
whiteColorPB.Color = material.WhiteColor.Color;
blackColorBP.Color = material.BlackColor.Color;
chkAlphaInterpolation.Bind(material, "ThresholdingAlphaInterpolation");
chkAlphaInterpolation.Bind(material, "AlphaInterpolation");
}
private STColorDialog colorDlg;

View File

@ -30,7 +30,7 @@ uniform int tevStage5A;
uniform int tevTexMode;
uniform int ThresholdingAlphaInterpolation;
uniform int AlphaInterpolation;
uniform int numTevStages;
uniform vec4 IndirectMat0;
@ -144,6 +144,8 @@ void main()
{
fragColor = vec4(1);
return;
vec4 textureMap0 = vec4(1);
vec4 textureMap1 = vec4(1);
vec4 textureMap2 = vec4(1);
@ -203,7 +205,7 @@ void main()
}
else
{
if (ThresholdingAlphaInterpolation != 0)
if (AlphaInterpolation != 0)
{
//Todo these need to interpolate and be smoother
if (textureMap0.a >= whiteColor.a) alpha = 1.0;

View File

@ -6,6 +6,8 @@ in vec2 vTexCoord0;
in vec2 vTexCoord1;
in vec2 vTexCoord2;
uniform mat4 rotationMatrix;
uniform mat4 modelViewMatrix;
uniform vec2 uvScale0;
uniform vec2 uvRotate0;
@ -52,5 +54,5 @@ void main()
TexCoord2 = SetFlip(texCoord0Transformed);
VertexColor = vColor;
gl_Position = modelViewMatrix * vec4(vPosition, 0, 1);
gl_Position = modelViewMatrix * rotationMatrix * vec4(vPosition, 0, 1);
}

View File

@ -26,7 +26,7 @@ uniform int tevStage3A;
uniform int tevStage4A;
uniform int tevStage5A;
uniform int ThresholdingAlphaInterpolation;
uniform int AlphaInterpolation;
uniform int numTevStages;
uniform sampler2D uvTestPattern;
@ -38,15 +38,15 @@ vec3 ColorOP(int type, vec4 color)
switch (type)
{
case 0: return color.rgb;
case 1: return vec3(1) - color.rgb;
case 1: return vec3(1.0) - color.rgb;
case 2: return color.aaa;
case 3: return vec3(1) - color.aaa;
case 3: return vec3(1.0) - color.aaa;
case 4: return color.rrr;
case 5: return vec3(1) - color.rrr;
case 5: return vec3(1.0) - color.rrr;
case 6: return color.ggg;
case 7: return vec3(1) - color.ggg;
case 7: return vec3(1.0) - color.ggg;
case 8: return color.bbb;
case 9: return vec3(1) - color.bbb;
case 9: return vec3(1.0) - color.bbb;
default: return color.rgb;
}
}
@ -159,7 +159,7 @@ void main()
}
else
{
if (ThresholdingAlphaInterpolation != 0)
if (AlphaInterpolation != 0)
{
//Todo these need to interpolate and be smoother
if (textureMap0.a >= whiteColor.a) alpha = 1.0;

View File

@ -1,4 +1,6 @@
uniform vec2 uvScale0;
#version 110
uniform vec2 uvScale0;
uniform float uvRotate0;
uniform vec2 uvTranslate0;
uniform int flipTexture;
@ -24,27 +26,32 @@ vec2 SetFlip(vec2 tex)
else if (flipTexture == 2) //FlipV
return vec2(1, -1) * tex + vec2(0, 1);
else if (flipTexture == 3) //Rotate90
return rotateUV(tex, radians(90.0));
{
float degreesR = 90.0;
return rotateUV(tex, radians(degreesR));
}
else if (flipTexture == 4) //Rotate180
return rotateUV(tex, radians(180.0));
{
float degreesR = 180.0;
return rotateUV(tex, radians(degreesR));
}
else if (flipTexture == 5) //Rotate270
return rotateUV(tex, radians(270.0));
{
float degreesR = 270.0;
return rotateUV(tex, radians(degreesR));
}
return outTexCoord;
}
vec2 SetTexCoordType(int type, vec2 tex)
{
vec2 outTexCoord = tex;
switch (type)
{
case 0: return tex; //Tex0
case 1: return tex; //Tex1
case 2: return tex; //Tex2
case 3: return tex; //Ortho
case 4: return tex; //Pane based
case 5: return tex; //Proj
}
if (type == 0) return tex; //Tex0
if (type == 1) return tex; //Tex1
if (type == 2) return tex; //Tex3
if (type == 3) return tex; //Ortho
if (type == 4) return tex; //Pane based
if (type == 5) return tex; //Proj
return outTexCoord;
}