Ejemplo n.º 1
0
        public override void Compile(CompileParams data)
        {
            base.Compile(data);

            floorTexture    = data.RenderContext.CreateTexture2D(new Bitmap(Textures + "floor_color_map.jpg"), textureFilteringFunctionType.LinearMipmapLinear);
            lightMapTexture = data.RenderContext.CreateTexture2D(new Bitmap(Textures + "floor_light_map.jpg"), textureFilteringFunctionType.LinearMipmapLinear);
        }
Ejemplo n.º 2
0
 private bool isShaderUpToDate(CompileParams p)
 {
     if (disableCache)
     {
         return(false);
     }
     return(File.Exists(p.CacheFilename));
 }
Ejemplo n.º 3
0
            public override void Compile(CompileParams data)
            {
                data.RenderContext.Compile(wireGraphicsData, (context, @params) =>
                {
                    context.DrawLines(wireVertices);
                }, null);

                base.Compile(data);
            }
Ejemplo n.º 4
0
        public ShaderBytecode CompileFromFile(string filename, string fx, ShaderMacro[] shaderMacros)
        {
            //WARNING: using ShaderFlags.SkipOptimization simply causes compiler to go berserk when using functions, they get skipped or smth
            //var bytecodeOri = ShaderBytecode.CompileFromFile(filename, "fx_5_0",
            //                               ShaderFlags.WarningsAreErrors | ShaderFlags.SkipOptimization |
            //                               ShaderFlags.Debug, EffectFlags.None, null, includeHandler);
            var includeHandler = new IncludeHandler();
            var compileParams  = new CompileParams(filename, "fx_5_0", ShaderFlags.OptimizationLevel3 | ShaderFlags.SkipValidation, EffectFlags.None, shaderMacros, includeHandler);
            //var compileParams = new CompileParams(filename, "fx_5_0", ShaderFlags.WarningsAreErrors | ShaderFlags.EnableStrictness | ShaderFlags.Debug, EffectFlags.None, shaderMacros, includeHandler);
            var ret = CompileFromFile(compileParams);

            LastCompiledFiles = includeHandler.IncludedFiles.ToArray();

            return(ret);
        }
Ejemplo n.º 5
0
        public ShaderBytecode CompileFromFile(CompileParams compileParams)
        {
            //TODO: check if filename is in a subfolder of RootShaderPath!!
            if (!FileHelper.IsFileInDirectory(new FileInfo(compileParams.Filename), new DirectoryInfo(RootShaderPath)))
            {
                throw new InvalidOperationException("Shader should be under the RootShaderPath!!");
            }

            if (!isShaderUpToDate(compileParams))
            {
                var code = ShaderBytecode.CompileFromFile(compileParams.Filename, compileParams.FX, compileParams.ShaderFlags, compileParams.EffectFlags, compileParams.ShaderMacros, compileParams.IncludeHandler);
                saveBytecodeToFile(code, compileParams.CacheFilename);
            }

            return(loadBytecodeFromFile(compileParams.CacheFilename));
        }
Ejemplo n.º 6
0
        public void NotifyEntityChanged(object sender, Common.EntityChangedEventArgs e)
        {
            if (sender is devDept.Eyeshot.Entities.Entity entity)
            {
                entity.Regen(0.0);
                entity.Compile(new CompileParams(this));
                Entities.UpdateBoundingBox();
                Invalidate();
            }

            else if (sender is Block block)
            {
                var compileParam = new CompileParams(this);
                block.Compile(compileParam);
                var blockRefs = Entities.Where(item => item is devDept.Eyeshot.Entities.BlockReference);


                string blockName = Blocks.First(item => item.Value == block).Key;

                foreach (var blockRef in blockRefs)
                {
                    if (((devDept.Eyeshot.Entities.BlockReference)blockRef).BlockName == blockName)
                    {
                        blockRef.Compile(compileParam);
                        blockRef.UpdateBoundingBox(new TraversalParams(null, this));
                    }
                }

                Entities.UpdateBoundingBox();
                Camera.UpdateLocation();
                Invalidate();
            }

            else
            {
                throw new NotImplementedException();
            }
        }