public Models(int numPipelines = 1) { NumPipelines = numPipelines; CheckDeviceCapabilities(); SharedModel = new SharedModel(); Images = new ImagesModel(SharedModel.ScaleShader); TextureCache = new TextureCache(Images); pixelValueShader = new PixelValueShader(SharedModel); polarConvertShader = new ConvertPolarShader(SharedModel.QuadShader); Export = new ExportModel(SharedModel); Filter = new FiltersModel(Images); //Gif = new GifModel(sharedModel.QuadShader); Progress = new ProgressModel(); for (int i = 0; i < numPipelines; ++i) { pipelines.Add(new ImagePipeline(i)); pipelines.Last().PropertyChanged += PipeOnPropertyChanged; } Pipelines = pipelines; stats = new StatisticsModel(SharedModel); thumbnail = new ThumbnailModel(SharedModel.QuadShader); // pipeline controller pipelineController = new PipelineController(this); }
public void Radius() { var tex = new TextureArray2D(IO.LoadImage(TestData.Directory + "checkers.dds")); var shader = new PixelValueShader(new SharedModel()); var color = shader.Run(tex, new Size3(1, 1, 0), 0, 0, 1); // should be 5 times black field + 4 times white field var expected = new Color(4.0f / 9.0f); Assert.IsTrue(expected.Equals(color, Color.Channel.Rgb)); color = shader.Run(tex, new Size3(1, 2, 0), 0, 0, 1); // should be 5 times white + 4 times black expected = new Color(5.0f / 9.0f); Assert.IsTrue(expected.Equals(color, Color.Channel.Rgb)); }
public void SmallImage() { var tex = new TextureArray2D(IO.LoadImage(TestData.Directory + "small.pfm")); var refColors = tex.GetPixelColors(0, 0); // recreate colors by picking them with the shader var shader = new PixelValueShader(new SharedModel()); var colors = new Color[refColors.Length]; for (int y = 0; y < tex.Size.Height; ++y) { for (int x = 0; x < tex.Size.Width; ++x) { colors[y * tex.Size.Width + x] = shader.Run(tex, new Size3(x, y, 0), 0, 0, 0); } } TestData.CompareColors(refColors, colors, Color.Channel.Rgb); }
public OpenGlModel(OpenGlContext context, ImagesModel images) { Debug.Assert(context.GlEnabled); Vao = new VertexArray(); CheckersShader = new CheckersShader(); samplerLinear = new Sampler(TextureMinFilter.Linear, TextureMagFilter.Linear); samplerLinearMip = new Sampler(TextureMinFilter.LinearMipmapLinear, TextureMagFilter.Linear); samplerNearest = new Sampler(TextureMinFilter.Nearest, TextureMagFilter.Nearest); samplerNearestMip = new Sampler(TextureMinFilter.NearestMipmapNearest, TextureMagFilter.Nearest); TextureCache = new TextureCacheModel(images, context); GetPixelShader = new PixelValueShader(); SrgbShader = new SrgbShader(); ExportShader = new PixelExportShader(); LinearMaxStatistics = new MaxStatistics(false); SrgbMaxStatistics = new MaxStatistics(true); LinearMinStatistics = new MinStatistics(false); SrgbMinStatistics = new MinStatistics(true); LinearAvgStatistics = new AverageStatistics(false, images); SrgbAvgStatistics = new AverageStatistics(true, images); }
public void Image3D() { var tex = new Texture3D(IO.LoadImage(TestData.Directory + "checkers3d.dds")); var shader = new PixelValueShader(new SharedModel()); var refColors = tex.GetPixelColors(0); var colors = new Color[refColors.Length]; int idx = 0; for (int z = 0; z < tex.Size.Depth; ++z) { for (int y = 0; y < tex.Size.Height; ++y) { for (int x = 0; x < tex.Size.Width; ++x) { colors[idx++] = shader.Run(tex, new Size3(x, y, z), 0, 0); } } } TestData.CompareColors(refColors, colors); }
internal StatisticsModel GetStatistics(ITexture image, int layer, int mipmap, PixelValueShader pixelValueShader, TextureCache cache) { var stats = new StatisticsModel { Min = minStatsShader.Run(pixelValueShader, image, cache, layer, mipmap), Max = maxStatsShader.Run(pixelValueShader, image, cache, layer, mipmap), Avg = avgStatsShader.Run(pixelValueShader, image, cache, layer, mipmap) }; return(stats); }