/// <summary>
        /// A function to create and save a new lookup-table with unmodified colors.
        /// Check the github readme for use.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="lutsize">32 or 16. 32 will result in a larger LUT which results in better images but worse performance</param>
        /// <param name="relativeFilePath">for example "Lut16.png". The base directory is where the .exe is started from</param>
        public void CreateLUT(GraphicsDevice graphics, LUTSizes lutsize, string relativeFilePath)
        {
            _renderTarget?.Dispose();

            _sizeParam.SetValue((float)(lutsize == LUTSizes.Size16 ? 16 : 32));
            _sizeRootParam.SetValue((float)(lutsize == LUTSizes.Size16 ? 4 : 8));
            int size = lutsize == LUTSizes.Size16 ? 16 * 4 : 32 * 8;

            _renderTarget = new RenderTarget2D(graphics, size, size, false, SurfaceFormat.Color, DepthFormat.None);

            graphics.SetRenderTarget(_renderTarget);

            _createLUTPass.Apply();
            _fullScreenTriangle.Draw(graphics);

            //Save this texture
            Stream stream = File.Create(relativeFilePath);

            _renderTarget.SaveAsPng(stream, _renderTarget.Width, _renderTarget.Height);
            stream.Dispose();
        }
Esempio n. 2
0
        /// <summary>
        /// A function to create and save a new lookup-table with unmodified colors.
        /// Check the github readme for use.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="lutsize">32 or 16. 32 will result in a larger LUT which results in better images but worse performance</param>
        /// <param name="relativeFilePath">for example "Lut16.png". The base directory is where the .exe is started from</param>
        public void CreateLUT(GraphicsDevice graphics, LUTSizes lutsize, string relativeFilePath)
        {
            _renderTarget?.Dispose();

            //_sizeParam.SetValue((float) ( lutsize == LUTSizes.Size16 ? 16 : lutsize == LUTSizes.Size32 ? 32 : 64));
            //_sizeRootParam.SetValue((float) (lutsize == LUTSizes.Size64 ? 8 : 4));
            Size = lutsize == LUTSizes.Size16 ? 16 : lutsize == LUTSizes.Size32 ? 32 : lutsize == LUTSizes.Size64 ? 64 : 4;
            int size = lutsize == LUTSizes.Size16 ? 16 * 4 : lutsize == LUTSizes.Size32 ? 32 * 8 : lutsize == LUTSizes.Size64 ? 64 * 8 : 4 * 2;

            _renderTarget = new RenderTarget2D(graphics, size, size / (lutsize == LUTSizes.Size32 ? 2 : 1), false, SurfaceFormat.Color, DepthFormat.None);

            graphics.SetRenderTarget(_renderTarget);

            _createLUTPass.Apply();
            _fsq.RenderFullscreenQuad(graphics);

            //Save this texture
            Stream stream = File.Create(relativeFilePath);

            _renderTarget.SaveAsPng(stream, _renderTarget.Width, _renderTarget.Height);
            stream.Dispose();
        }