From c3007a980e9c3895821a3f52ff761b5e72322808 Mon Sep 17 00:00:00 2001 From: "SND\\AstrorEnales_cp" Date: Thu, 17 Nov 2011 19:31:46 +0000 Subject: [PATCH] - Fixed the OpenTK reference in GL render system - Improved the gl shader bytes generation alot, their now way smaller and kinda safe against outside manipulation --- .../ANX.Framework.Windows.GL3.csproj | 5 +- .../ANX.Framework.Windows.GL3/EffectGL3.cs | 103 ++++++- .../ShaderByteCode.cs | 266 ++++-------------- Tools/StockShaderCodeGenerator/Compiler.cs | 5 +- 4 files changed, 147 insertions(+), 232 deletions(-) diff --git a/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj index 16b01064..d43e5f9b 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj +++ b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj @@ -32,9 +32,8 @@ 4 - - False - ..\lib\OpenTK\OpenTK.dll + + ..\..\lib\OpenTK\OpenTK.dll diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs index a1e8118a..ba8894c2 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs @@ -5,6 +5,7 @@ using ANX.Framework.Graphics; using ANX.Framework.NonXNA; using OpenTK.Graphics.OpenGL; using System.Text; +using System.Security.Cryptography; #region License @@ -121,16 +122,8 @@ namespace ANX.Framework.Windows.GL3 public EffectGL3(Stream vertexShaderByteCode, Stream pixelShaderByteCode) { - byte[] vertexBytes = new byte[vertexShaderByteCode.Length]; - vertexShaderByteCode.Read(vertexBytes, 0, - (int)vertexShaderByteCode.Length); - - byte[] fragmentBytes = new byte[pixelShaderByteCode.Length]; - pixelShaderByteCode.Read(fragmentBytes, 0, - (int)pixelShaderByteCode.Length); - - CreateShader(Encoding.ASCII.GetString(vertexBytes), - Encoding.ASCII.GetString(fragmentBytes)); + CreateShader(LoadShaderCode(vertexShaderByteCode), + LoadShaderCode(pixelShaderByteCode)); } /// @@ -139,10 +132,7 @@ namespace ANX.Framework.Windows.GL3 /// The byte code of the shader. public EffectGL3(Stream byteCode) { - byte[] byteData = new byte[byteCode.Length]; - byteCode.Read(byteData, 0, (int)byteCode.Length); - - string source = Encoding.ASCII.GetString(byteData); + string source = LoadShaderCode(byteCode); string[] parts = source.Split(new string[] { FragmentSeparator }, StringSplitOptions.RemoveEmptyEntries); @@ -211,7 +201,90 @@ namespace ANX.Framework.Windows.GL3 #region CompileShader (for external) public static byte[] CompileShader(string effectCode) { - return Encoding.ASCII.GetBytes(effectCode); + #region Source Cleanup + // We wanna clean up the shader a little bit, so we remove + // empty lines, spaces and tabs at beginning and end and also + // remove comments. + List lines = new List(effectCode.Split('\n')); + for (int index = lines.Count - 1; index >= 0; index--) + { + lines[index] = lines[index].Trim(); + if (String.IsNullOrEmpty(lines[index]) || + lines[index].StartsWith("//")) + { + lines.RemoveAt(index); + continue; + } + + // TODO: add /**/ comment checking and removing. + } + + effectCode = ""; + foreach (string line in lines) + { + effectCode += line + "\n"; + } + + // Now to some additional cleanup + string[] minimizables = + { + " * ", " = ", " + ", " / ", " - ", ", ", + }; + + foreach (string mizable in minimizables) + { + effectCode = effectCode.Replace(mizable, mizable.Trim()); + } + + effectCode = effectCode.Replace("\n{\n", "{\n"); + effectCode = effectCode.Replace("\n}\n", "}\n"); + #endregion + + MemoryStream stream = new MemoryStream(); + BinaryWriter writer = new BinaryWriter(stream); + + // First of all writer the shader code (which is already preceeded + // by a length identifier, making it harder to manipulate the code) + writer.Write(effectCode); + + // And now we additionally generate a sha hash so it nearly becomes + // impossible to manipulate the shader. + SHA512Managed sha = new SHA512Managed(); + byte[] data = stream.ToArray(); + byte[] hash = sha.ComputeHash(data); + // The hash is added to the end of the stream. + writer.Write(hash); + writer.Flush(); + sha.Dispose(); + + return stream.ToArray(); + } + #endregion + + #region LoadShaderCode + private static string LoadShaderCode(Stream stream) + { + BinaryReader reader = new BinaryReader(stream); + // First load the source. + string source = reader.ReadString(); + // And now check if it was manipulated. + SHA512Managed sha = new SHA512Managed(); + int lengthRead = (int)stream.Position; + stream.Position = 0; + byte[] data = reader.ReadBytes(lengthRead); + byte[] hash = sha.ComputeHash(data); + sha.Dispose(); + byte[] loadedHash = reader.ReadBytes(64); + for (int index = 0; index < hash.Length; index++) + { + if (hash[index] != loadedHash[index]) + { + throw new InvalidDataException("Failed to load the shader " + + "because the data got manipulated!"); + } + } + + return source; } #endregion diff --git a/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs b/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs index 367e15eb..77b33b3b 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs @@ -54,218 +54,60 @@ namespace ANX.Framework.Windows.GL3 #region SpriteBatchShader internal static byte[] SpriteBatchByteCode = new byte[] { - 047, - 047, 013, 010, 047, 047, 032, 084, 104, 105, 115, 032, 102, 105, 108, 101, 032, 105, 115, 032, 112, - 097, 114, 116, 032, 111, 102, 032, 116, 104, 101, 032, 065, 078, 088, 046, 070, 114, 097, 109, 101, - 119, 111, 114, 107, 032, 099, 114, 101, 097, 116, 101, 100, 032, 098, 121, 032, 116, 104, 101, 032, - 034, 065, 078, 088, 046, 070, 114, 097, 109, 101, 119, 111, 114, 107, 032, 100, 101, 118, 101, 108, - 111, 112, 101, 114, 032, 103, 114, 111, 117, 112, 034, 046, 013, 010, 047, 047, 013, 010, 047, 047, - 032, 084, 104, 105, 115, 032, 102, 105, 108, 101, 032, 105, 115, 032, 114, 101, 108, 101, 097, 115, - 101, 100, 032, 117, 110, 100, 101, 114, 032, 116, 104, 101, 032, 077, 115, 045, 080, 076, 032, 108, - 105, 099, 101, 110, 115, 101, 046, 013, 010, 047, 047, 013, 010, 047, 047, 013, 010, 047, 047, 013, - 010, 047, 047, 032, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, 080, 117, 098, 108, 105, 099, - 032, 076, 105, 099, 101, 110, 115, 101, 032, 040, 077, 115, 045, 080, 076, 041, 013, 010, 047, 047, - 013, 010, 047, 047, 032, 084, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 103, 111, - 118, 101, 114, 110, 115, 032, 117, 115, 101, 032, 111, 102, 032, 116, 104, 101, 032, 097, 099, 099, - 111, 109, 112, 097, 110, 121, 105, 110, 103, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 032, - 073, 102, 032, 121, 111, 117, 032, 117, 115, 101, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, - 097, 114, 101, 044, 032, 121, 111, 117, 032, 097, 099, 099, 101, 112, 116, 032, 116, 104, 105, 115, - 032, 108, 105, 099, 101, 110, 115, 101, 046, 032, 013, 010, 047, 047, 032, 073, 102, 032, 121, 111, - 117, 032, 100, 111, 032, 110, 111, 116, 032, 097, 099, 099, 101, 112, 116, 032, 116, 104, 101, 032, - 108, 105, 099, 101, 110, 115, 101, 044, 032, 100, 111, 032, 110, 111, 116, 032, 117, 115, 101, 032, - 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047, 013, 010, 047, - 047, 032, 049, 046, 068, 101, 102, 105, 110, 105, 116, 105, 111, 110, 115, 013, 010, 047, 047, 032, - 032, 032, 084, 104, 101, 032, 116, 101, 114, 109, 115, 032, 034, 114, 101, 112, 114, 111, 100, 117, - 099, 101, 044, 034, 032, 034, 114, 101, 112, 114, 111, 100, 117, 099, 116, 105, 111, 110, 044, 034, - 032, 034, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032, 119, 111, 114, 107, 115, 044, 034, - 032, 097, 110, 100, 032, 034, 100, 105, 115, 116, 114, 105, 098, 117, 116, 105, 111, 110, 034, 032, - 104, 097, 118, 101, 032, 116, 104, 101, 032, 115, 097, 109, 101, 032, 109, 101, 097, 110, 105, 110, - 103, 032, 013, 010, 047, 047, 032, 032, 032, 104, 101, 114, 101, 032, 097, 115, 032, 117, 110, 100, - 101, 114, 032, 085, 046, 083, 046, 032, 099, 111, 112, 121, 114, 105, 103, 104, 116, 032, 108, 097, - 119, 046, 013, 010, 047, 047, 032, 032, 032, 065, 032, 034, 099, 111, 110, 116, 114, 105, 098, 117, - 116, 105, 111, 110, 034, 032, 105, 115, 032, 116, 104, 101, 032, 111, 114, 105, 103, 105, 110, 097, - 108, 032, 115, 111, 102, 116, 119, 097, 114, 101, 044, 032, 111, 114, 032, 097, 110, 121, 032, 097, - 100, 100, 105, 116, 105, 111, 110, 115, 032, 111, 114, 032, 099, 104, 097, 110, 103, 101, 115, 032, - 116, 111, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047, - 032, 032, 032, 065, 032, 034, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 034, 032, 105, - 115, 032, 097, 110, 121, 032, 112, 101, 114, 115, 111, 110, 032, 116, 104, 097, 116, 032, 100, 105, - 115, 116, 114, 105, 098, 117, 116, 101, 115, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, - 098, 117, 116, 105, 111, 110, 032, 117, 110, 100, 101, 114, 032, 116, 104, 105, 115, 032, 108, 105, - 099, 101, 110, 115, 101, 046, 013, 010, 047, 047, 032, 032, 032, 034, 076, 105, 099, 101, 110, 115, - 101, 100, 032, 112, 097, 116, 101, 110, 116, 115, 034, 032, 097, 114, 101, 032, 097, 032, 099, 111, - 110, 116, 114, 105, 098, 117, 116, 111, 114, 039, 115, 032, 112, 097, 116, 101, 110, 116, 032, 099, - 108, 097, 105, 109, 115, 032, 116, 104, 097, 116, 032, 114, 101, 097, 100, 032, 100, 105, 114, 101, - 099, 116, 108, 121, 032, 111, 110, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, - 116, 105, 111, 110, 046, 013, 010, 047, 047, 013, 010, 047, 047, 032, 050, 046, 071, 114, 097, 110, - 116, 032, 111, 102, 032, 082, 105, 103, 104, 116, 115, 013, 010, 047, 047, 032, 032, 032, 040, 065, - 041, 032, 067, 111, 112, 121, 114, 105, 103, 104, 116, 032, 071, 114, 097, 110, 116, 045, 032, 083, - 117, 098, 106, 101, 099, 116, 032, 116, 111, 032, 116, 104, 101, 032, 116, 101, 114, 109, 115, 032, - 111, 102, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 044, 032, 105, 110, 099, - 108, 117, 100, 105, 110, 103, 032, 116, 104, 101, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099, - 111, 110, 100, 105, 116, 105, 111, 110, 115, 032, 097, 110, 100, 032, 108, 105, 109, 105, 116, 097, - 116, 105, 111, 110, 115, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 105, 110, 032, - 115, 101, 099, 116, 105, 111, 110, 032, 051, 044, 032, 101, 097, 099, 104, 032, 099, 111, 110, 116, - 114, 105, 098, 117, 116, 111, 114, 032, 103, 114, 097, 110, 116, 115, 032, 121, 111, 117, 032, 097, - 032, 110, 111, 110, 045, 101, 120, 099, 108, 117, 115, 105, 118, 101, 044, 032, 119, 111, 114, 108, - 100, 119, 105, 100, 101, 044, 032, 114, 111, 121, 097, 108, 116, 121, 045, 102, 114, 101, 101, 032, - 099, 111, 112, 121, 114, 105, 103, 104, 116, 032, 108, 105, 099, 101, 110, 115, 101, 032, 116, 111, - 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 114, 101, 112, 114, 111, 100, 117, 099, - 101, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 044, 032, - 112, 114, 101, 112, 097, 114, 101, 032, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032, 119, - 111, 114, 107, 115, 032, 111, 102, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, - 116, 105, 111, 110, 044, 032, 097, 110, 100, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101, - 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 013, 010, 047, - 047, 032, 032, 032, 032, 032, 032, 032, 111, 114, 032, 097, 110, 121, 032, 100, 101, 114, 105, 118, - 097, 116, 105, 118, 101, 032, 119, 111, 114, 107, 115, 032, 116, 104, 097, 116, 032, 121, 111, 117, - 032, 099, 114, 101, 097, 116, 101, 046, 013, 010, 047, 047, 032, 032, 032, 040, 066, 041, 032, 080, - 097, 116, 101, 110, 116, 032, 071, 114, 097, 110, 116, 045, 032, 083, 117, 098, 106, 101, 099, 116, - 032, 116, 111, 032, 116, 104, 101, 032, 116, 101, 114, 109, 115, 032, 111, 102, 032, 116, 104, 105, - 115, 032, 108, 105, 099, 101, 110, 115, 101, 044, 032, 105, 110, 099, 108, 117, 100, 105, 110, 103, - 032, 116, 104, 101, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099, 111, 110, 100, 105, 116, 105, - 111, 110, 115, 032, 097, 110, 100, 032, 108, 105, 109, 105, 116, 097, 116, 105, 111, 110, 115, 032, - 105, 110, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 115, 101, 099, 116, 105, 111, - 110, 032, 051, 044, 032, 101, 097, 099, 104, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, - 114, 032, 103, 114, 097, 110, 116, 115, 032, 121, 111, 117, 032, 097, 032, 110, 111, 110, 045, 101, - 120, 099, 108, 117, 115, 105, 118, 101, 044, 032, 119, 111, 114, 108, 100, 119, 105, 100, 101, 044, - 032, 114, 111, 121, 097, 108, 116, 121, 045, 102, 114, 101, 101, 032, 108, 105, 099, 101, 110, 115, - 101, 032, 117, 110, 100, 101, 114, 032, 105, 116, 115, 032, 108, 105, 099, 101, 110, 115, 101, 100, - 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 112, 097, 116, 101, 110, 116, 115, 032, 116, - 111, 032, 109, 097, 107, 101, 044, 032, 104, 097, 118, 101, 032, 109, 097, 100, 101, 044, 032, 117, - 115, 101, 044, 032, 115, 101, 108, 108, 044, 032, 111, 102, 102, 101, 114, 032, 102, 111, 114, 032, - 115, 097, 108, 101, 044, 032, 105, 109, 112, 111, 114, 116, 044, 032, 097, 110, 100, 047, 111, 114, - 032, 111, 116, 104, 101, 114, 119, 105, 115, 101, 032, 100, 105, 115, 112, 111, 115, 101, 032, 111, - 102, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 032, 013, - 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 105, 110, 032, 116, 104, 101, 032, 115, 111, 102, - 116, 119, 097, 114, 101, 032, 111, 114, 032, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032, - 119, 111, 114, 107, 115, 032, 111, 102, 032, 116, 104, 101, 032, 099, 111, 110, 116, 114, 105, 098, - 117, 116, 105, 111, 110, 032, 105, 110, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, - 101, 046, 013, 010, 047, 047, 013, 010, 047, 047, 032, 051, 046, 067, 111, 110, 100, 105, 116, 105, - 111, 110, 115, 032, 097, 110, 100, 032, 076, 105, 109, 105, 116, 097, 116, 105, 111, 110, 115, 013, - 010, 047, 047, 032, 032, 032, 040, 065, 041, 032, 078, 111, 032, 084, 114, 097, 100, 101, 109, 097, - 114, 107, 032, 076, 105, 099, 101, 110, 115, 101, 045, 032, 084, 104, 105, 115, 032, 108, 105, 099, - 101, 110, 115, 101, 032, 100, 111, 101, 115, 032, 110, 111, 116, 032, 103, 114, 097, 110, 116, 032, - 121, 111, 117, 032, 114, 105, 103, 104, 116, 115, 032, 116, 111, 032, 117, 115, 101, 032, 097, 110, - 121, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 115, 039, 032, 110, 097, 109, 101, - 044, 032, 108, 111, 103, 111, 044, 032, 111, 114, 032, 116, 114, 097, 100, 101, 109, 097, 114, 107, - 115, 046, 013, 010, 047, 047, 032, 032, 032, 040, 066, 041, 032, 073, 102, 032, 121, 111, 117, 032, - 098, 114, 105, 110, 103, 032, 097, 032, 112, 097, 116, 101, 110, 116, 032, 099, 108, 097, 105, 109, - 032, 097, 103, 097, 105, 110, 115, 116, 032, 097, 110, 121, 032, 099, 111, 110, 116, 114, 105, 098, - 117, 116, 111, 114, 032, 111, 118, 101, 114, 032, 112, 097, 116, 101, 110, 116, 115, 032, 116, 104, - 097, 116, 032, 121, 111, 117, 032, 099, 108, 097, 105, 109, 032, 097, 114, 101, 032, 105, 110, 102, - 114, 105, 110, 103, 101, 100, 032, 098, 121, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, - 114, 101, 044, 032, 121, 111, 117, 114, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, - 112, 097, 116, 101, 110, 116, 032, 108, 105, 099, 101, 110, 115, 101, 032, 102, 114, 111, 109, 032, - 115, 117, 099, 104, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 032, 116, 111, 032, - 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 032, 101, 110, 100, 115, 032, 097, 117, - 116, 111, 109, 097, 116, 105, 099, 097, 108, 108, 121, 046, 013, 010, 047, 047, 032, 032, 032, 040, - 067, 041, 032, 073, 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101, - 032, 097, 110, 121, 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032, - 115, 111, 102, 116, 119, 097, 114, 101, 044, 032, 121, 111, 117, 032, 109, 117, 115, 116, 032, 114, - 101, 116, 097, 105, 110, 032, 097, 108, 108, 032, 099, 111, 112, 121, 114, 105, 103, 104, 116, 044, - 032, 112, 097, 116, 101, 110, 116, 044, 032, 116, 114, 097, 100, 101, 109, 097, 114, 107, 044, 032, - 097, 110, 100, 032, 097, 116, 116, 114, 105, 098, 117, 116, 105, 111, 110, 032, 013, 010, 047, 047, - 032, 032, 032, 032, 032, 032, 032, 110, 111, 116, 105, 099, 101, 115, 032, 116, 104, 097, 116, 032, - 097, 114, 101, 032, 112, 114, 101, 115, 101, 110, 116, 032, 105, 110, 032, 116, 104, 101, 032, 115, - 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047, 032, 032, 032, 040, 068, 041, 032, 073, - 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101, 032, 097, 110, 121, - 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032, 115, 111, 102, 116, - 119, 097, 114, 101, 032, 105, 110, 032, 115, 111, 117, 114, 099, 101, 032, 099, 111, 100, 101, 032, - 102, 111, 114, 109, 044, 032, 121, 111, 117, 032, 109, 097, 121, 032, 100, 111, 032, 115, 111, 032, - 111, 110, 108, 121, 032, 117, 110, 100, 101, 114, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, - 110, 115, 101, 032, 098, 121, 032, 105, 110, 099, 108, 117, 100, 105, 110, 103, 013, 010, 047, 047, - 032, 032, 032, 032, 032, 032, 032, 097, 032, 099, 111, 109, 112, 108, 101, 116, 101, 032, 099, 111, - 112, 121, 032, 111, 102, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 119, - 105, 116, 104, 032, 121, 111, 117, 114, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 105, 111, - 110, 046, 032, 073, 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101, - 032, 097, 110, 121, 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032, - 115, 111, 102, 116, 119, 097, 114, 101, 032, 105, 110, 032, 099, 111, 109, 112, 105, 108, 101, 100, - 032, 111, 114, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 111, 098, 106, 101, 099, - 116, 032, 099, 111, 100, 101, 032, 102, 111, 114, 109, 044, 032, 121, 111, 117, 032, 109, 097, 121, - 032, 111, 110, 108, 121, 032, 100, 111, 032, 115, 111, 032, 117, 110, 100, 101, 114, 032, 097, 032, - 108, 105, 099, 101, 110, 115, 101, 032, 116, 104, 097, 116, 032, 099, 111, 109, 112, 108, 105, 101, - 115, 032, 119, 105, 116, 104, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 046, - 013, 010, 047, 047, 032, 032, 032, 040, 069, 041, 032, 084, 104, 101, 032, 115, 111, 102, 116, 119, - 097, 114, 101, 032, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 100, 032, 034, 097, 115, 045, - 105, 115, 046, 034, 032, 089, 111, 117, 032, 098, 101, 097, 114, 032, 116, 104, 101, 032, 114, 105, - 115, 107, 032, 111, 102, 032, 117, 115, 105, 110, 103, 032, 105, 116, 046, 032, 084, 104, 101, 032, - 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 115, 032, 103, 105, 118, 101, 032, 110, 111, - 032, 101, 120, 112, 114, 101, 115, 115, 032, 119, 097, 114, 114, 097, 110, 116, 105, 101, 115, 044, - 032, 103, 117, 097, 114, 097, 110, 116, 101, 101, 115, 044, 013, 010, 047, 047, 032, 032, 032, 032, - 032, 032, 032, 111, 114, 032, 099, 111, 110, 100, 105, 116, 105, 111, 110, 115, 046, 032, 089, 111, - 117, 032, 109, 097, 121, 032, 104, 097, 118, 101, 032, 097, 100, 100, 105, 116, 105, 111, 110, 097, - 108, 032, 099, 111, 110, 115, 117, 109, 101, 114, 032, 114, 105, 103, 104, 116, 115, 032, 117, 110, - 100, 101, 114, 032, 121, 111, 117, 114, 032, 108, 111, 099, 097, 108, 032, 108, 097, 119, 115, 032, - 119, 104, 105, 099, 104, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099, - 097, 110, 110, 111, 116, 032, 099, 104, 097, 110, 103, 101, 046, 032, 084, 111, 032, 116, 104, 101, - 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 101, 120, 116, 101, 110, 116, 032, 112, 101, - 114, 109, 105, 116, 116, 101, 100, 032, 117, 110, 100, 101, 114, 032, 121, 111, 117, 114, 032, 108, - 111, 099, 097, 108, 032, 108, 097, 119, 115, 044, 032, 116, 104, 101, 032, 099, 111, 110, 116, 114, - 105, 098, 117, 116, 111, 114, 115, 032, 101, 120, 099, 108, 117, 100, 101, 032, 116, 104, 101, 032, - 105, 109, 112, 108, 105, 101, 100, 032, 119, 097, 114, 114, 097, 110, 116, 105, 101, 115, 032, 111, - 102, 032, 109, 101, 114, 099, 104, 097, 110, 116, 097, 098, 105, 108, 105, 116, 121, 044, 032, 102, - 105, 116, 110, 101, 115, 115, 032, 102, 111, 114, 032, 097, 032, 013, 010, 047, 047, 032, 032, 032, - 032, 032, 032, 032, 112, 097, 114, 116, 105, 099, 117, 108, 097, 114, 032, 112, 117, 114, 112, 111, - 115, 101, 032, 097, 110, 100, 032, 110, 111, 110, 045, 105, 110, 102, 114, 105, 110, 103, 101, 109, - 101, 110, 116, 046, 013, 010, 013, 010, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, - 032, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 013, 010, 013, - 010, 047, 047, 013, 010, 047, 047, 032, 086, 101, 114, 116, 101, 120, 032, 083, 104, 097, 100, 101, - 114, 013, 010, 047, 047, 013, 010, 013, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, - 111, 105, 100, 041, 013, 010, 123, 013, 010, 009, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, - 110, 032, 061, 032, 103, 108, 095, 077, 111, 100, 101, 108, 086, 105, 101, 119, 080, 114, 111, 106, - 101, 099, 116, 105, 111, 110, 077, 097, 116, 114, 105, 120, 032, 042, 032, 103, 108, 095, 086, 101, - 114, 116, 101, 120, 059, 013, 010, 125, 013, 010, 013, 010, 035, 035, 033, 102, 114, 097, 103, 109, - 101, 110, 116, 033, 035, 035, 013, 010, 013, 010, 047, 047, 013, 010, 047, 047, 032, 070, 114, 097, - 103, 109, 101, 110, 116, 032, 083, 104, 097, 100, 101, 114, 013, 010, 047, 047, 013, 010, 013, 010, - 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 013, 010, 123, 013, 010, - 009, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111, 114, 032, 061, 032, 118, 101, 099, 052, - 040, 049, 046, 048, 044, 032, 049, 046, 048, 044, 032, 049, 046, 048, 044, 032, 049, 046, 048, 041, - 059, 013, 010, 125, 013, 010, 013, 010, 047, 042, 013, 010, 084, 101, 120, 116, 117, 114, 101, 050, - 068, 060, 102, 108, 111, 097, 116, 052, 062, 032, 084, 101, 120, 116, 117, 114, 101, 032, 058, 032, - 114, 101, 103, 105, 115, 116, 101, 114, 040, 116, 048, 041, 059, 013, 010, 032, 032, 032, 115, 097, - 109, 112, 108, 101, 114, 032, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114, - 032, 058, 032, 114, 101, 103, 105, 115, 116, 101, 114, 040, 115, 048, 041, 059, 013, 010, 013, 010, - 115, 116, 114, 117, 099, 116, 032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073, - 110, 112, 117, 116, 013, 010, 123, 013, 010, 009, 102, 108, 111, 097, 116, 052, 032, 112, 111, 115, - 032, 058, 032, 080, 079, 083, 073, 084, 073, 079, 078, 059, 013, 010, 009, 102, 108, 111, 097, 116, - 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079, 082, 059, 013, 010, 009, 102, 108, 111, - 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067, 079, 079, 082, 068, 048, 059, - 013, 010, 125, 059, 013, 010, 013, 010, 115, 116, 114, 117, 099, 116, 032, 080, 105, 120, 101, 108, - 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 013, 010, 123, 013, 010, 009, 102, 108, 111, - 097, 116, 052, 032, 112, 111, 115, 032, 058, 032, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, - 078, 059, 013, 010, 009, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, - 076, 079, 082, 059, 013, 010, 009, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, - 084, 069, 088, 067, 079, 079, 082, 068, 048, 059, 013, 010, 125, 059, 013, 010, 013, 010, 080, 105, - 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 032, 083, 112, 114, 105, 116, - 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 032, 086, 101, 114, 116, 101, - 120, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 032, 105, 110, 112, 117, 116, 032, 041, - 013, 010, 123, 013, 010, 009, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, - 117, 116, 032, 111, 117, 116, 112, 117, 116, 032, 061, 032, 040, 080, 105, 120, 101, 108, 083, 104, - 097, 100, 101, 114, 073, 110, 112, 117, 116, 041, 048, 059, 013, 010, 009, 013, 010, 009, 111, 117, - 116, 112, 117, 116, 046, 112, 111, 115, 032, 061, 032, 109, 117, 108, 040, 105, 110, 112, 117, 116, - 046, 112, 111, 115, 044, 032, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, - 109, 041, 059, 013, 010, 009, 111, 117, 116, 112, 117, 116, 046, 099, 111, 108, 032, 061, 032, 105, - 110, 112, 117, 116, 046, 099, 111, 108, 059, 013, 010, 009, 111, 117, 116, 112, 117, 116, 046, 116, - 101, 120, 032, 061, 032, 105, 110, 112, 117, 116, 046, 116, 101, 120, 059, 013, 010, 013, 010, 009, - 114, 101, 116, 117, 114, 110, 032, 111, 117, 116, 112, 117, 116, 059, 013, 010, 125, 013, 010, 013, - 010, 102, 108, 111, 097, 116, 052, 032, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083, - 104, 097, 100, 101, 114, 040, 032, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, - 112, 117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 032, 058, 032, 083, 086, 095, 084, 097, 114, - 103, 101, 116, 013, 010, 123, 013, 010, 009, 114, 101, 116, 117, 114, 110, 032, 084, 101, 120, 116, - 117, 114, 101, 046, 083, 097, 109, 112, 108, 101, 040, 084, 101, 120, 116, 117, 114, 101, 083, 097, - 109, 112, 108, 101, 114, 044, 032, 105, 110, 112, 117, 116, 046, 116, 101, 120, 041, 032, 042, 032, - 105, 110, 112, 117, 116, 046, 099, 111, 108, 059, 013, 010, 125, 013, 010, 013, 010, 116, 101, 099, - 104, 110, 105, 113, 117, 101, 049, 048, 032, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, - 105, 113, 117, 101, 013, 010, 123, 013, 010, 009, 112, 097, 115, 115, 032, 083, 112, 114, 105, 116, - 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 013, 010, 009, 123, 013, 010, 009, 009, 083, 101, - 116, 071, 101, 111, 109, 101, 116, 114, 121, 083, 104, 097, 100, 101, 114, 040, 032, 048, 032, 041, - 059, 013, 010, 009, 009, 083, 101, 116, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, - 040, 032, 067, 111, 109, 112, 105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 118, 115, 095, - 052, 095, 048, 044, 032, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, - 100, 101, 114, 040, 041, 032, 041, 032, 041, 059, 013, 010, 009, 009, 083, 101, 116, 080, 105, 120, - 101, 108, 083, 104, 097, 100, 101, 114, 040, 032, 067, 111, 109, 112, 105, 108, 101, 083, 104, 097, - 100, 101, 114, 040, 032, 112, 115, 095, 052, 095, 048, 044, 032, 083, 112, 114, 105, 116, 101, 080, - 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040, 041, 032, 041, 032, 041, 059, 013, 010, 009, - 125, 013, 010, 125, 013, 010, 042, 047 + 224, + 007, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120, + 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, + 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, + 103, 108, 095, 077, 111, 100, 101, 108, 086, 105, 101, 119, 080, 114, 111, 106, 101, 099, 116, 105, + 111, 110, 077, 097, 116, 114, 105, 120, 042, 103, 108, 095, 086, 101, 114, 116, 101, 120, 059, 125, + 010, 035, 035, 033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 118, 111, 105, 100, + 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097, 103, + 067, 111, 108, 111, 114, 061, 118, 101, 099, 052, 040, 049, 046, 048, 044, 049, 046, 048, 044, 049, + 046, 048, 044, 049, 046, 048, 041, 059, 125, 010, 047, 042, 010, 084, 101, 120, 116, 117, 114, 101, + 050, 068, 060, 102, 108, 111, 097, 116, 052, 062, 032, 084, 101, 120, 116, 117, 114, 101, 032, 058, + 032, 114, 101, 103, 105, 115, 116, 101, 114, 040, 116, 048, 041, 059, 010, 115, 097, 109, 112, 108, + 101, 114, 032, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114, 032, 058, 032, + 114, 101, 103, 105, 115, 116, 101, 114, 040, 115, 048, 041, 059, 010, 115, 116, 114, 117, 099, 116, + 032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 123, 010, + 102, 108, 111, 097, 116, 052, 032, 112, 111, 115, 032, 058, 032, 080, 079, 083, 073, 084, 073, 079, + 078, 059, 010, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079, + 082, 059, 010, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067, + 079, 079, 082, 068, 048, 059, 010, 125, 059, 010, 115, 116, 114, 117, 099, 116, 032, 080, 105, 120, + 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 123, 010, 102, 108, 111, 097, 116, + 052, 032, 112, 111, 115, 032, 058, 032, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 059, + 010, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079, 082, 059, + 010, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067, 079, 079, + 082, 068, 048, 059, 010, 125, 059, 010, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, + 110, 112, 117, 116, 032, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, + 100, 101, 114, 040, 032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073, 110, 112, + 117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 123, 010, 080, 105, 120, 101, 108, 083, 104, 097, + 100, 101, 114, 073, 110, 112, 117, 116, 032, 111, 117, 116, 112, 117, 116, 061, 040, 080, 105, 120, + 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 041, 048, 059, 010, 111, 117, 116, + 112, 117, 116, 046, 112, 111, 115, 061, 109, 117, 108, 040, 105, 110, 112, 117, 116, 046, 112, 111, + 115, 044, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 041, 059, 010, + 111, 117, 116, 112, 117, 116, 046, 099, 111, 108, 061, 105, 110, 112, 117, 116, 046, 099, 111, 108, + 059, 010, 111, 117, 116, 112, 117, 116, 046, 116, 101, 120, 061, 105, 110, 112, 117, 116, 046, 116, + 101, 120, 059, 010, 114, 101, 116, 117, 114, 110, 032, 111, 117, 116, 112, 117, 116, 059, 125, 010, + 102, 108, 111, 097, 116, 052, 032, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083, 104, + 097, 100, 101, 114, 040, 032, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, + 117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 032, 058, 032, 083, 086, 095, 084, 097, 114, 103, + 101, 116, 123, 010, 114, 101, 116, 117, 114, 110, 032, 084, 101, 120, 116, 117, 114, 101, 046, 083, + 097, 109, 112, 108, 101, 040, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114, + 044, 105, 110, 112, 117, 116, 046, 116, 101, 120, 041, 042, 105, 110, 112, 117, 116, 046, 099, 111, + 108, 059, 125, 010, 116, 101, 099, 104, 110, 105, 113, 117, 101, 049, 048, 032, 083, 112, 114, 105, + 116, 101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 123, 010, 112, 097, 115, 115, 032, 083, 112, + 114, 105, 116, 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 123, 010, 083, 101, 116, 071, 101, + 111, 109, 101, 116, 114, 121, 083, 104, 097, 100, 101, 114, 040, 032, 048, 032, 041, 059, 010, 083, + 101, 116, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 032, 067, 111, 109, 112, + 105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 118, 115, 095, 052, 095, 048, 044, 083, 112, + 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 041, 032, 041, + 032, 041, 059, 010, 083, 101, 116, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040, 032, + 067, 111, 109, 112, 105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 112, 115, 095, 052, 095, + 048, 044, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040, + 041, 032, 041, 032, 041, 059, 125, 010, 125, 010, 042, 047, 010, 117, 140, 064, 187, 232, 054, 126, + 209, 103, 145, 103, 013, 029, 122, 079, 091, 098, 241, 220, 158, 076, 040, 008, 035, 172, 166, 125, + 213, 214, 199, 171, 220, 149, 178, 155, 164, 238, 077, 175, 178, 130, 078, 077, 229, 197, 006, 010, + 071, 037, 113, 028, 110, 096, 111, 079, 211, 240, 031, 083, 045, 193, 025, 040, 058 }; #endregion //SpriteBatchShader diff --git a/Tools/StockShaderCodeGenerator/Compiler.cs b/Tools/StockShaderCodeGenerator/Compiler.cs index ce4ff0eb..fc3318e5 100644 --- a/Tools/StockShaderCodeGenerator/Compiler.cs +++ b/Tools/StockShaderCodeGenerator/Compiler.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using ANX.Framework.Windows.DX10; using ANX.Framework.Windows.GL3; +using System.IO; #endregion // Using Statements @@ -69,9 +70,9 @@ namespace StockShaderCodeGenerator Console.WriteLine("-> loading shader for type '{0}' (file: '{1}')", s.Type, s.Source); String source = String.Empty; - if (System.IO.File.Exists(s.Source)) + if (File.Exists(s.Source)) { - source = System.IO.File.ReadAllText(s.Source); + source = File.ReadAllText(s.Source); } Console.Write("--> compiling shader... ");