示例#1
0
        public void Setup(OperatorPart outputOp, double width, double height)
        {
            if (_outputOp == outputOp && _width == (int)width && _height == (int)height)
            {
                return;
            }

            try
            {
                Dispose();

                _outputOp = outputOp;
                _width    = (int)width;
                _height   = (int)height;
                _samples  = 2;

                _renderer = new DefaultRenderer();

                _texture = ShaderResourceView.FromFile(D3DDevice.Device, "./assets-common/image/white.png");

                _renderTargetResource = null;
                ResourceManager.ValidateRenderTargetResource(ref _renderTargetResource, _outputOp, D3DDevice.Device, _width, _height);
                _renderTargetView = new RenderTargetView(D3DDevice.Device, _renderTargetResource.Texture);

                _renderTargetDepthResource = null;
                ResourceManager.ValidateDepthStencilResource(ref _renderTargetDepthResource, _outputOp, D3DDevice.Device, _width, _height);
                var depthViewDesc = new DepthStencilViewDescription();
                depthViewDesc.Format    = Format.D32_Float;
                depthViewDesc.Dimension = DepthStencilViewDimension.Texture2D;

                _renderTargetDepthView = new DepthStencilView(D3DDevice.Device, _renderTargetDepthResource.Texture, depthViewDesc);

                _gpuSyncer = new BlockingGpuSyncer(D3DDevice.Device);

                D3DDevice.Device.ImmediateContext.OutputMerger.SetTargets(_renderTargetDepthView, _renderTargetView);
                _viewport = new ViewportF(0, 0, _width, _height, 0.0f, 1.0f);
                D3DDevice.Device.ImmediateContext.Rasterizer.SetViewport(_viewport);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to setup imagefile-sequence: {0}", e.Message);
            }
        }
示例#2
0
        public void Setup(OperatorPart outputOpPart, double startTime = 0, double endTime = 184, double frameRate   = 30, double width                = 1920, double height = 1080,
                          string fileExtension = "png", bool skipExistingFiles            = false, string directory = "output", string filenameFormat = "[T]", SharpDX.DXGI.Format imageFormat = Format.R8G8B8A8_UNorm)
        {
            try
            {
                Dispose();

                _outputOpPart      = outputOpPart;
                _directory         = directory;
                _fileNameFormat    = filenameFormat;
                _startTime         = startTime;
                _endTime           = endTime;
                _frameRate         = frameRate;
                _width             = (int)width;
                _height            = (int)height;
                _samples           = 2;
                _fileExtension     = fileExtension.ToLower();
                _skipExistingFiles = skipExistingFiles;

                _defaultContext = new OperatorPartContext(0.0f);
                _defaultContext.Variables.Add("Screensize.Width", _width);
                _defaultContext.Variables.Add("Screensize.Height", _height);
                _defaultContext.Variables.Add("AspectRatio", (float)_width / _height);
                _defaultContext.Variables.Add("Samples", _samples);
                _defaultContext.Variables.Add("FullScreen", 0.0f);
                _defaultContext.Variables.Add("LoopMode", 0.0f);
                _defaultContext.ImageBufferFormat = imageFormat;

                _frameTime = 1.0 / _frameRate;

                Directory.CreateDirectory(_directory);

                _renderer = new DefaultRenderer();

                _texture = ShaderResourceView.FromFile(D3DDevice.Device, "./assets-common/image/white.png");


                _renderTargetResource = null;
                ResourceManager.ValidateRenderTargetResource(ref _renderTargetResource, _outputOpPart, D3DDevice.Device, _width, _height, imageFormat);
                _renderTargetView = new RenderTargetView(D3DDevice.Device, _renderTargetResource.Texture);

                _renderDepthResource = null;
                ResourceManager.ValidateDepthStencilResource(ref _renderDepthResource, _outputOpPart, D3DDevice.Device, _width, _height);
                var depthViewDesc = new DepthStencilViewDescription();
                depthViewDesc.Format    = Format.D32_Float;
                depthViewDesc.Dimension = DepthStencilViewDimension.Texture2D;

                _renderTargetDepthView = new DepthStencilView(D3DDevice.Device, _renderDepthResource.Texture, depthViewDesc);

                _gpuSyncer = new BlockingGpuSyncer(D3DDevice.Device);

                D3DDevice.Device.ImmediateContext.OutputMerger.SetTargets(_renderTargetDepthView, _renderTargetView);
                _viewport = new ViewportF(0, 0, _width, _height, 0.0f, 1.0f);
                D3DDevice.Device.ImmediateContext.Rasterizer.SetViewport(_viewport);


                var timeAccessorCollector = new OperatorPart.CollectOpPartFunctionsOfType <OperatorPartTraits.ITimeAccessor>();
                _outputOpPart.TraverseWithFunction(timeAccessorCollector, null);
                _timeAccessorOpPartFunctions = new List <OperatorPart.Function>();
                foreach (var opPartFunction in timeAccessorCollector.CollectedOpPartFunctions)
                {
                    _timeAccessorOpPartFunctions.Add(opPartFunction as OperatorPart.Function);
                }
                _currentTime = _startTime;
            }
            catch (Exception e)
            {
                Logger.Error("Failed to setup image-sequence {0}", e.Message);
            }
        }