示例#1
0
        public static Effect Load(string filePathAndName)
        {
            string extension = Path.GetExtension(filePathAndName);
            string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string fullPath = Path.Combine(baseDir, filePathAndName);

            if (!File.Exists(fullPath))
            {
                Debugger.Break();
            }

            if (extension == ".fx")
            {
                EffectCompiler compiler = new EffectCompiler();
                var result = compiler.CompileFromFile(fullPath, EffectCompilerFlags.Debug);

                if (result.HasErrors)
                {
                    var thing = result.Logger.Messages;
                    Debugger.Break();
                    return null;
                }
                else
                    return new Effect(Engine.GraphicsContext.Device, result.EffectData);
            }

            if (extension == ".fxo")
            {
                // todo
            }

            return null;
        }
示例#2
0
 public static EffectData CompileEffect(string path)
 {
     var effectCompiler = new EffectCompiler();
     var compilerResult = effectCompiler.CompileFromFile(path,
         EffectCompilerFlags.Debug | EffectCompilerFlags.SkipOptimization);
     if (compilerResult.HasErrors)
     {
         throw new Exception();
     }
     return compilerResult.EffectData;
 }
        private void ReloadShader()
        {
            if(Effect != null)
                Effect.Dispose();

            EffectCompilerFlags compilerFlags = EffectCompilerFlags.None;
            #if DEBUG
            compilerFlags |= EffectCompilerFlags.Debug;
            #endif
            var shaderCompiler = new EffectCompiler();

            // relaxed cone mapping compute shader
            var compileResult = shaderCompiler.CompileFromFile(shaderFilename, compilerFlags, shaderMacros);
            if (compileResult.HasErrors)
            {
                System.Console.WriteLine(compileResult.Logger.Messages);
                System.Diagnostics.Debugger.Break();
            }
            Effect = new Effect(graphicsDevice, compileResult.EffectData);

            if (OnReload != null)
                OnReload();
        }