Пример #1
0
 public ImagesCorrelationStats(ITextureCache cache)
 {
     this.Cache  = cache;
     Image1      = new ImageVarianceStats(cache);
     Image2      = new ImageVarianceStats(cache);
     Correlation = cache.GetTexture();
 }
Пример #2
0
        public ImageLoader(int maxCacheCount = 15, int maxDownloadNum = 5)
        {
            var memoryCache = new MemoryCache(null, maxCacheCount);
            var diskCache   = new DiskCache(memoryCache);

            m_TextureCache = new NetworkCache(diskCache, maxDownloadNum);
        }
Пример #3
0
 public virtual void Reset(ITextureCache cache)
 {
     if (typeof(TTexture) == typeof(ITexture))
     {
         cache.PutTempTexture(OutputTexture as ITexture);
     }
 }
 public ImageVarianceStats(ITextureCache cache)
 {
     Cache    = cache;
     Luma     = cache.GetTexture();
     Expected = cache.GetTexture();
     Variance = cache.GetTexture();
 }
Пример #5
0
        public virtual void Render(ITextureCache cache)
        {
            if (Updated)
            {
                return;
            }

            Updated = true;

            foreach (var filter in InputFilters)
            {
                filter.Render(cache);
            }

            var inputTextures = InputFilters.Select(f => f.OutputTexture);

            OutputTexture = cache.GetTexture(OutputSize);

            Render(inputTextures);

            foreach (var filter in InputFilters)
            {
                if (filter.LastDependentIndex <= FilterIndex)
                {
                    filter.Reset(cache);
                }
            }
        }
Пример #6
0
 public VolumeView(ModelsEx models) : base(models)
 {
     smooth = new SmoothVolumeShader(models);
     cube   = new CubeVolumeShader(models);
     emptySpaceSkippingShader = new EmptySpaceSkippingShader();
     cubeSkippingShader       = new CubeSkippingShader();
     displayEx    = (RayCastingDisplayModel)models.Display.ExtendedViewData;
     helpTextures = new HelpTextureData[models.NumPipelines];
     textureCache = new ImageModelTextureCache(models.Images, Format.R8_UInt, true, false);
 }
Пример #7
0
 public AGSSaveLoad(Resolver resolver, IGameFactory factory,
                    ITextureCache textures, IGame game, IFileSystem fileSystem)
 {
     _resolver   = resolver;
     _factory    = factory;
     _textures   = textures;
     _state      = game.State;
     _events     = game.Events;
     _fileSystem = fileSystem;
 }
Пример #8
0
 public GLImageRenderer(ITextureCache textures, ITextureFactory textureFactory,
                        IGLColorBuilder colorBuilder, IGLTextureRenderer renderer, IGLUtils glUtils)
 {
     _textures       = textures;
     _getTextureFunc = textureFactory.CreateTexture;  //Creating a delegate in advance to avoid memory allocations on critical path
     _colorBuilder   = colorBuilder;
     _renderer       = renderer;
     _glUtils        = glUtils;
     _colorAdjusters = new IHasImage[2];
 }
Пример #9
0
 public AGSSerializationContext(IGameFactory factory, ITextureCache textures,
                                Resolver resolver, IGLUtils glUtils)
 {
     Factory        = factory;
     GLUtils        = glUtils;
     Textures       = textures;
     _contracts     = new ContractsFactory();
     Resolver       = resolver;
     _rewireActions = new List <Action <IGameState> > ();
 }
Пример #10
0
        public virtual void Reset(ITextureCache cache)
        {
            Updated = false;

            if (OutputTexture != null)
            {
                cache.PutTexture(OutputTexture);
            }

            OutputTexture = null;
        }
Пример #11
0
        private ITextureCache GetCache(ITexture src)
        {
            // determine which texture cache to use
            ITextureCache cache = customTexCache;

            if (cache == null || !cache.IsCompatibleWith(src))
            {
                customTexCache?.Dispose();
                cache = customTexCache = new TextureCache(src, Format.R32_Float, true);
            }

            return(cache);
        }
Пример #12
0
#pragma warning restore CS0067

        public GLLabelRenderer(ITextureCache textures, ITextureFactory textureFactory,
                               IBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes,
                               IGLUtils glUtils, IGraphicsBackend graphics, IFontLoader fonts,
                               IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _bindings = new List <IComponentBinding>();
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _glUtils                     = glUtils;
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _viewport                    = viewportMatrix;
            _textureRenderer             = textureRenderer;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();
            _bgRenderer                  = new GLImageRenderer(textures, textureFactory, colorBuilder, _textureRenderer, glUtils);

            _colorBuilder = colorBuilder;

            TextVisible           = true;
            TextBackgroundVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(TextBackgroundVisible))
                {
                    return;
                }
                onBoundingBoxShouldChange();
                if (e.PropertyName == nameof(Config))
                {
                    subscribeTextConfigChanges();
                }
            };
            _shouldUpdateBoundingBoxes = true;
        }
Пример #13
0
        public GLGraphicsFactory(ITextureCache textures, Resolver resolver, IGLUtils glUtils,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IRenderThread renderThread,
                                 IResourceLoader resources, IIconFactory icons, IBrushLoader brushes, IRenderMessagePump messagePump)
        {
            Icons              = icons;
            Brushes            = brushes;
            _renderThread      = renderThread;
            _textures          = textures;
            _resolver          = resolver;
            _resources         = resources;
            _bitmapLoader      = bitmapLoader;
            _spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics, messagePump);

            AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin();
        }
Пример #14
0
 public AGSImageComponent(IHasImage image, IGraphicsFactory factory, IRenderPipeline pipeline,
                          IGLTextureRenderer renderer, ITextureCache textures,
                          ITextureFactory textureFactory, IGLColorBuilder colorBuilder)
 {
     IsImageVisible          = true;
     _getTextureFunc         = textureFactory.CreateTexture; //Creating a delegate in advance to avoid memory allocations on critical path
     _textures               = textures;
     _colorBuilder           = colorBuilder;
     _image                  = image;
     _factory                = factory;
     _colorAdjusters         = new IHasImage[2];
     _image.PropertyChanged += onPropertyChanged;
     _pipeline               = pipeline;
     _boxesPool              = new ObjectPool <AGSBoundingBoxes>(_ => new AGSBoundingBoxes(), 2);
     _instructionPool        = new ObjectPool <Instruction>(instructionPool => new Instruction(instructionPool, _boxesPool, renderer), 2);
 }
Пример #15
0
 public MaterialConverter(EventHub hub, MemoryTracker memTracker, ITextureCache textureCache, IOutput <SyncedData <Material> > output)
     : base(hub, memTracker, output)
 {
     m_Importer     = new SyncMaterialImporter();
     m_TextureCache = textureCache;
 }
 public URPMaterialConverter(EventHub hub, MemoryTracker memTracker, ITextureCache textureCache, IOutput <SyncedData <Material> > output, IReflectMaterialConverter converter)
     : base(hub, memTracker, textureCache, output)
 {
     ReflectMaterialManager.RegisterConverter(converter);
 }
 public SampleMaterialConverter(EventHub hub, MemoryTracker memTracker, ITextureCache textureCache, IOutput <SyncedData <Material> > output, Shader opaqueShader, Shader transparentShader)
     : base(hub, memTracker, textureCache, output)
 {
     m_OpaqueShader      = opaqueShader;
     m_TransparentShader = transparentShader;
 }
Пример #18
0
 public override void Reset(ITextureCache cache)
 {
 }
Пример #19
0
 public MemoryCache(ITextureCache textureCache, int maxCacheCount = 15)
 {
     m_MaxCacheCount = maxCacheCount;
     m_TextureCache  = textureCache;
 }
Пример #20
0
 public void Render(ITextureCache cache)
 {
 }
Пример #21
0
 public virtual void Reset(ITextureCache cache)
 {
     cache.PutTempTexture(OutputTexture);
 }
 public void SetMaterialProperties(SyncMaterial syncMaterial, Material material, ITextureCache textureCache)
 {
     StandardShaderHelper.ComputeMaterial(syncMaterial, material, textureCache);
 }
Пример #23
0
        public void Run(ITexture src, ITexture dst, int srcMipmap, int dstMipmap, bool hasAlpha, UploadBuffer upload, ITextureCache cache)
        {
            Debug.Assert(cache.IsCompatibleWith(src));
            Debug.Assert(src.NumLayers == dst.NumLayers);
            Debug.Assert(dstMipmap < dst.NumMipmaps && dstMipmap >= 0);
            Debug.Assert(srcMipmap < src.NumMipmaps && dstMipmap >= 0);

            var dstSize = dst.Size.GetMip(dstMipmap);
            var srcSize = src.Size.GetMip(srcMipmap);
            var cbuffer = new BufferData
            {
                HasAlpha = hasAlpha ? 1 : 0
            };


            var      tmpTex1 = cache.GetTexture();
            ITexture tmpTex2 = null;

            if (src.Is3D)
            {
                tmpTex2 = cache.GetTexture();
            }


            foreach (var srcLm in src.LayerMipmap.LayersOfMipmap(srcMipmap))
            {
                cbuffer.Layer     = srcLm.Layer;
                cbuffer.DstSize   = srcSize;
                cbuffer.DstSize.X = dstSize.X;

                ExecuteDimension(ref cbuffer, upload, src.Is3D, 0, srcSize, src.GetSrView(srcLm), tmpTex1.GetUaView(srcMipmap));
                // var tst = tmpTex1.GetPixelColors(layer, 0);

                cbuffer.DstSize.Y = dstSize.Y;
                if (src.Is3D)
                {
                    ExecuteDimension(ref cbuffer, upload, src.Is3D, 1, srcSize, tmpTex1.GetSrView(srcLm), tmpTex2.GetUaView(srcMipmap));

                    cbuffer.DstSize.Z = dstSize.Z;
                    ExecuteDimension(ref cbuffer, upload, src.Is3D, 2, srcSize, tmpTex2.GetSrView(srcLm), dst.GetUaView(dstMipmap));
                }
                else
                {
                    ExecuteDimension(ref cbuffer, upload, src.Is3D, 1, srcSize, tmpTex1.GetSrView(srcLm), dst.GetUaView(dstMipmap));
                }
            }

            cache.StoreTexture(tmpTex1);
            if (tmpTex2 != null)
            {
                cache.StoreTexture(tmpTex2);
            }
        }
Пример #24
0
        protected static void AssignMap(Material material, string sourceId, string id, SyncMap map, ITextureCache textureCache) // TODO Use int ID
        {
            Texture2D texture2D = null;

            if (map.TextureId != SyncId.None)
            {
                var textureKey = StreamKey.FromSyncId <SyncTexture>(sourceId, map.TextureId);
                texture2D = textureCache.GetTexture(textureKey);
            }

            material.SetTexture(id, texture2D);

            var offset = map.Offset;

            material.SetTextureOffset(id, new Vector2(offset.X, offset.Y));

            var tiling = map.Tiling;

            material.SetTextureScale(id, new Vector2(tiling.X, tiling.Y));
        }
Пример #25
0
        protected override void SetMaterialPropertiesInternal(SyncedData <SyncMaterial> syncedMaterial, Material material, ITextureCache textureCache)
        {
            var syncMaterial = syncedMaterial.data;
            var sourceId     = syncedMaterial.key.source;

            ExtractBasicMaterialInfo(syncMaterial, out var transparent, out var emission, out var color);

            // Albedo
            material.SetColor("_BaseColor", color);
            AssignMap(material, sourceId, "_BaseColorMap", syncMaterial.AlbedoMap, textureCache);

            // Metallic
            material.SetFloat("_Metallic", syncMaterial.Metallic);
            if (syncMaterial.MetallicMap.TextureId != SyncId.None)
            {
                // TODO
            }

            // Smoothness
            material.SetFloat("_Smoothness", syncMaterial.Glossiness);
            if (syncMaterial.GlossinessMap.TextureId != SyncId.None)
            {
                // TODO
            }

            // Normal
            if (syncMaterial.NormalMap.TextureId != SyncId.None)
            {
                AssignMap(material, sourceId, "_NormalMap", syncMaterial.NormalMap, textureCache);
                material.SetFloat("_NormalScale", syncMaterial.NormalScale);
                material.EnableKeyword("_NORMALMAP");
                material.EnableKeyword("_NORMALMAP_TANGENT_SPACE");
            }

            // Transparency
            if (!emission && transparent)
            {
                material.SetColor("_Color", color);
                material.SetFloat("_SurfaceType", 1);
                material.SetFloat("_BlendMode", 0);
                material.SetFloat("_DstBlend", 10);
                material.SetFloat("_AlphaDstBlend", 10);
                material.SetFloat("_AlphaCutoffEnable", 0);
                material.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
                material.renderQueue = (int)RenderQueue.Transparent;

                material.EnableKeyword("_BLENDMODE_ALPHA");
                material.EnableKeyword("_BLENDMODE_PRESERVE_SPECULAR_LIGHTING");
                material.EnableKeyword("_ENABLE_FOG_ON_TRANSPARENT");
                material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
            }

            // Cutout
            // TODO Not supported?

            // Emission
            if (emission)
            {
                var emissionColor = ImportersUtils.GetUnityColor(syncMaterial.Emission);
                material.SetColor("_EmissiveColor", emissionColor);
                material.SetColor("_EmissiveColorLDR", emissionColor);

                if (syncMaterial.EmissionMap.TextureId != SyncId.None)
                {
                    AssignMap(material, sourceId, "_EmissiveColorMap", syncMaterial.EmissionMap, textureCache);
                }

                material.SetInt("_UseEmissiveIntensity", 1);
                //material.EnableKeyword("_Emissive");
                material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
            }
        }
Пример #26
0
 protected abstract void SetMaterialPropertiesInternal(SyncedData <SyncMaterial> syncMaterial, Material material, ITextureCache textureCache);
Пример #27
0
 public void SetMaterialProperties(SyncedData <SyncMaterial> syncMaterial, Material material, ITextureCache textureCache)
 {
     SetMaterialPropertiesInternal(syncMaterial, material, textureCache);
 }
Пример #28
0
 public static void ComputeMaterial(SyncedData <SyncMaterial> syncMaterial, Material material, ITextureCache textureCache)
 {
     material.name   = syncMaterial.data.Name;
     material.shader = currentConverter.GetShader(syncMaterial.data);
     currentConverter.SetMaterialProperties(syncMaterial, material, textureCache);
 }
 public URPMaterialConverter(ITextureCache textureCache, IOutput <SyncedData <Material> > output, IReflectMaterialConverter converter)
     : base(textureCache, output)
 {
     ReflectMaterialManager.RegisterConverter(converter);
 }
        public void Run(ITexture src, ITexture dst, int srcMipmap, int dstMipmap, bool hasAlpha, UploadBuffer upload, ITextureCache cache)
        {
            // first execute the box scaling shader
            boxScalingShader.Run(src, dst, srcMipmap, dstMipmap, hasAlpha, upload, cache);

            // run fast 3x3 gaussian shader
            var guidanceTex = cache.GetTexture();

            gaussShader.Run(dst, guidanceTex, dstMipmap, hasAlpha, upload);

            // perform filter with guidance texture
            coreShader.Run(src, guidanceTex, dst, srcMipmap, dstMipmap, hasAlpha, upload);

            cache.StoreTexture(guidanceTex);
        }