/// <summary> /// Generates the csharp code from a xkfx file. /// </summary> /// <param name="xkfxShaderCode">The PDXFX shader code.</param> /// <param name="filePath">The file path.</param> /// <returns>System.String.</returns> /// <exception cref="System.InvalidOperationException"></exception> public static string GenerateCsharp(string xkfxShaderCode, string filePath) { // Compile var shader = XenkoShaderParser.PreProcessAndParse(xkfxShaderCode, filePath); // Try to generate a mixin code. var loggerResult = new LoggerResult(); var shaderKeyGenerator = new ShaderMixinCodeGen(shader, loggerResult); if (shaderKeyGenerator.Run()) { return(shaderKeyGenerator.Text); } throw new InvalidOperationException(loggerResult.ToString()); }
/// <summary> /// Generates the csharp code from a xkfx file. /// </summary> /// <param name="xkfxShaderCode">The PDXFX shader code.</param> /// <param name="filePath">The file path.</param> /// <returns>System.String.</returns> /// <exception cref="System.InvalidOperationException"></exception> public static string GenerateCsharp(string xkfxShaderCode, string filePath) { // In .xkfx, shader has been renamed to effect, in order to avoid ambiguities with HLSL and .xksl var macros = new [] { new Xenko.Core.Shaders.Parser.ShaderMacro("shader", "effect") }; // Compile var shader = XenkoShaderParser.PreProcessAndParse(xkfxShaderCode, filePath, macros); // Try to generate a mixin code. var loggerResult = new LoggerResult(); var shaderKeyGenerator = new ShaderMixinCodeGen(shader, loggerResult); if (shaderKeyGenerator.Run()) { return(shaderKeyGenerator.Text); } throw new InvalidOperationException(loggerResult.ToString()); }