From 2e268e6283cf3339bdab90d11d0e9b3a9b41fc89 Mon Sep 17 00:00:00 2001 From: Razmoth <32140579+Razmoth@users.noreply.github.com> Date: Sat, 10 Feb 2024 08:09:39 +0400 Subject: [PATCH] - [Core] Added shader flags. --- AssetStudio.Utility/ShaderConverter.cs | 5 ++++- AssetStudio/Classes/Shader.cs | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/AssetStudio.Utility/ShaderConverter.cs b/AssetStudio.Utility/ShaderConverter.cs index 5e2eadf..6669c41 100644 --- a/AssetStudio.Utility/ShaderConverter.cs +++ b/AssetStudio.Utility/ShaderConverter.cs @@ -690,7 +690,10 @@ namespace AssetStudio { sb.Append($"[{m_Attribute}] "); } - //TODO Flag + foreach (var flag in Enum.GetValues().Where(x => m_Prop.m_Flags.HasFlag(x))) + { + sb.Append($"[{flag}] "); + } sb.Append($"{m_Prop.m_Name} (\"{m_Prop.m_Description}\", "); switch (m_Prop.m_Type) { diff --git a/AssetStudio/Classes/Shader.cs b/AssetStudio/Classes/Shader.cs index 9ad7b0f..240dcf1 100644 --- a/AssetStudio/Classes/Shader.cs +++ b/AssetStudio/Classes/Shader.cs @@ -89,13 +89,27 @@ namespace AssetStudio Int = 5 }; + [Flags] + public enum SerializedPropertyFlag + { + HideInInspector = 1 << 0, + PerRendererData = 1 << 1, + NoScaleOffset = 1 << 2, + Normal = 1 << 3, + HDR = 1 << 4, + Gamma = 1 << 5, + NonModifiableTextureData = 1 << 6, + MainTexture = 1 << 7, + MainColor = 1 << 8, + } + public class SerializedProperty { public string m_Name; public string m_Description; public string[] m_Attributes; public SerializedPropertyType m_Type; - public uint m_Flags; + public SerializedPropertyFlag m_Flags; public float[] m_DefValue; public SerializedTextureProperty m_DefTexture; @@ -105,7 +119,7 @@ namespace AssetStudio m_Description = reader.ReadAlignedString(); m_Attributes = reader.ReadStringArray(); m_Type = (SerializedPropertyType)reader.ReadInt32(); - m_Flags = reader.ReadUInt32(); + m_Flags = (SerializedPropertyFlag)reader.ReadUInt32(); m_DefValue = reader.ReadSingleArray(4); m_DefTexture = new SerializedTextureProperty(reader); }