bool DoBuild(string _effectSource) { CreateUIParameters(_effectSource); OutputClear(); var options = new Options(); // Parse the MGFX file expanding includes, macros, and returning the techniques. ShaderInfo shaderInfo; try { options.Debug = true; options.Profile = ShaderProfile.DirectX_11; options.SourceFile = string.Empty; options.OutputFile = string.Empty; var strpathApp = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); shaderInfo = ShaderInfo.FromString(_effectSource, strpathApp, options, this); } catch (Exception ex) { OutputAppend(ex.Message); OutputAppend("Failed to parse !"); return(false); } // Create the effect object. EffectObject effect; var shaderErrorsAndWarnings = string.Empty; try { effect = EffectObject.CompileEffect(shaderInfo, out shaderErrorsAndWarnings); if (!string.IsNullOrEmpty(shaderErrorsAndWarnings)) { OutputAppend(shaderErrorsAndWarnings); } } catch (ShaderCompilerException) { // Write the compiler errors and warnings and let the user know what happened. OutputAppend(shaderErrorsAndWarnings); OutputAppend("Failed to compile !"); return(false); } catch (Exception ex) { // First write all the compiler errors and warnings. if (!string.IsNullOrEmpty(shaderErrorsAndWarnings)) { OutputAppend(shaderErrorsAndWarnings); } // If we have an exception message then write that. if (!string.IsNullOrEmpty(ex.Message)) { OutputAppend(ex.Message); } // Let the user know what happened. OutputAppend("Unexpected error compiling !"); return(false); } OutputAppend("Shader successed Compiled !"); //Create Effect for Game View using (MemoryStream stream = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(stream); effect.Write(bw, options); byte[] bytecode = stream.ToArray(); m_game.SetEffectBytesCode(bytecode); } return(true); }