private void ResizeMirrorBuffers() { _mirrorBuffer?.Resize(DeviceContextHolder, Width, Height, null); _mirrorDepthBuffer?.Resize(DeviceContextHolder, Width, Height, null); _mirrorBlurBuffer?.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); _temporaryBuffer?.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); }
private TargetResourceTexture GetLimits(ShaderResourceView view, Size size, Format?format = null) { TargetResourceTexture result = null; for (var i = Math.Max(size.Width, size.Height) / 4; i >= 1 || result == null; i /= 4) { if (i < 1) { i = 1; } var current = result; result = TargetResourceTexture.Create(format ?? Format.R8G8B8A8_UNorm); result.Resize(DeviceContextHolder, i, i, null); var j = i; var input = current?.View ?? view; UseEffect(e => { e.FxSize.Set(new Vector4(j, j, 1f / j, 1f / j)); e.FxInputMap.SetResource(input); (current == null ? e.TechFindLimitsFirstStep : e.TechFindLimits).DrawAllPasses(DeviceContext, 6); }, result); current?.Dispose(); } return(result); }
protected override void ResizeInner() { _f0Buffer.Resize(DeviceContextHolder, Width, Height, null); _f1Buffer.Resize(DeviceContextHolder, Width, Height, null); _fBlendBuffer.Resize(DeviceContextHolder, Width, Height, null); _fSummBuffer.Resize(DeviceContextHolder, Width, Height, null); _a0Buffer.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); _a1Buffer.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); _aSummBuffer.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); }
private void ResizeBuffers() { _bufferF.Resize(DeviceContextHolder, Width, Height, SampleDescription); _bufferFSsaaFxaa?.Resize(DeviceContextHolder, Width, Height, null); _bufferA?.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); _bufferAColorGrading?.Resize(DeviceContextHolder, ActualWidth, ActualHeight, null); _bufferH1?.Resize(DeviceContextHolder, ActualWidth / 2, ActualHeight / 2, null); _bufferH2?.Resize(DeviceContextHolder, ActualWidth / 2, ActualHeight / 2, null); }
protected override void ResizeInner() { base.ResizeInner(); _gDepthBuffer.Resize(DeviceContextHolder, Width, Height, SampleDescription); _gBufferBase.Resize(DeviceContextHolder, Width, Height, SampleDescription); _gBufferNormal.Resize(DeviceContextHolder, Width, Height, SampleDescription); _gBufferMaps.Resize(DeviceContextHolder, Width, Height, SampleDescription); _temporaryDepthBuffer.Resize(DeviceContextHolder, Width, Height, SampleDescription); _temporaryBuffer0.Resize(DeviceContextHolder, Width, Height, SampleDescription); _temporaryBuffer1.Resize(DeviceContextHolder, Width, Height, SampleDescription); _temporaryBuffer2.Resize(DeviceContextHolder, Width, Height, SampleDescription); _temporaryBuffer3.Resize(DeviceContextHolder, Width, Height, SampleDescription); _outputBuffer.Resize(DeviceContextHolder, Width, Height, SampleDescription); }
private void PrepareOutlineBuffer() { if (_outlineBuffer != null) { return; } _outlineBuffer = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _outlineDepthBuffer = TargetResourceDepthTexture.Create(); if (!InitiallyResized) { return; } _outlineBuffer.Resize(DeviceContextHolder, Width, Height, null); _outlineDepthBuffer.Resize(DeviceContextHolder, Width, Height, null); }
public void OnResize(DeviceContextHolder holder) { var width = holder.Width; var height = holder.Height; var i = 4 * 3; foreach (var texture in _textures) { texture.Resize(holder, Math.Max(width / i, 1), Math.Max(height / i, 1), null); i *= 4; } _bloomTexture.Resize(holder, width, height, null); _tempTexture.Resize(holder, width, height, null); }
public void Prepare(DeviceContextHolder holder, bool useMsaa) { if (_effect == null) { OnInitialize(holder); } var width = holder.Width; var height = holder.Height; var sampleDescription = useMsaa ? holder.SampleDescription : (SampleDescription?)null; if (BufferScene.Resize(holder, width, height, sampleDescription)) { BufferBaseReflection.Resize(holder, width, height, sampleDescription); BufferResult.Resize(holder, width, height, null); } holder.DeviceContext.ClearRenderTargetView(BufferBaseReflection.TargetView, (Color4) new Vector4(0)); }
public void OnInitialize(DeviceContextHolder holder) { _effect = holder.GetEffect <EffectPpHdr>(); _blurHelper = holder.GetHelper <BlurHelper>(); _textures = Enumerable.Range(0, DownsamplerAdaptationCycles) .Select(x => TargetResourceTexture.Create(Format.R16G16B16A16_Float)) .ToArray(); _averateColor = Enumerable.Range(0, 2).Select(x => { var t = TargetResourceTexture.Create(Format.R16G16B16A16_Float); t.Resize(holder, 1, 1, null); return(t); }).ToArray(); _newAverageColor = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _newAverageColor.Resize(holder, 1, 1, null); _bloomTexture = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _tempTexture = TargetResourceTexture.Create(Format.R16G16B16A16_Float); }
protected override void ResizeInner() { base.ResizeInner(); _outlineBuffer?.Resize(DeviceContextHolder, Width, Height, null); _outlineDepthBuffer?.Resize(DeviceContextHolder, Width, Height, null); }
protected override void ResizeInner() { _buffer0.Resize(DeviceContextHolder, Width, Height, null); _buffer1.Resize(DeviceContextHolder, Width, Height, null); ResetCamera(); }
private void ResizeGBuffers() { _gBufferNormals?.Resize(DeviceContextHolder, Width, Height, SampleDescription); _gBufferDepth?.Resize(DeviceContextHolder, Width, Height, SampleDescription); }
private void ResizeSsaoBuffers() { _aoBuffer?.Resize(DeviceContextHolder, Width, Height, null); }
private void ResizeSslrBuffers() { _sslrBufferScene?.Resize(DeviceContextHolder, Width, Height, SampleDescription); _sslrBufferResult?.Resize(DeviceContextHolder, Width, Height, SampleDescription); _sslrBufferBaseReflection?.Resize(DeviceContextHolder, Width, Height, SampleDescription); }
public virtual void Shot(double multiplier, double downscale, Stream outputStream, bool lossless) { var resolutionMultiplier = ResolutionMultiplier; var format = lossless ? ImageFileFormat.Png : ImageFileFormat.Jpg; ResolutionMultiplier = multiplier; if (Equals(downscale, 1d) && !UseMsaa) { // Simplest case: existing buffer will do just great, so let’s use it Draw(); Texture2D.ToStream(DeviceContext, _renderBuffer, format, outputStream); } else { // More complicated situation: we need to temporary replace existing _renderBuffer // with a custom one // Preparing temporary replacement for _renderBuffer… if (_shotRenderBuffer == null) { // Let’s keep all those buffers in memory between shots to make series shooting faster _shotRenderBuffer = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); } _shotRenderBuffer.Resize(DeviceContextHolder, Width, Height, SampleDescription); // If we won’t call Resize() here, it will be called in Draw(), and then swap chain will // be recreated in a wrong time if (_resized) { Resize(); _resized = false; } // Destroying current swap chain if needed var swapChainMode = _swapChain != null; if (swapChainMode) { DisposeHelper.Dispose(ref _swapChain); } // Replacing _renderBuffer… var renderView = _renderView; _renderView = _shotRenderBuffer.TargetView; // Calculating output width and height and, if needed, preparing downscaled buffer… var outputWidth = (Width * downscale).RoundToInt(); var outputHeight = (Height * downscale).RoundToInt(); if (!Equals(downscale, 1d)) { if (_shotDownsampleTexture == null) { _shotDownsampleTexture = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); } _shotDownsampleTexture.Resize(DeviceContextHolder, outputWidth, outputHeight, null); } // Ready to draw! Draw(); // For MSAA, we need to copy the result into a texture without MSAA enabled to save it later TargetResourceTexture result; if (UseMsaa) { if (_shotMsaaTemporaryTexture == null) { _shotMsaaTemporaryTexture = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); } _shotMsaaTemporaryTexture.Resize(DeviceContextHolder, Width, Height, null); DeviceContextHolder.GetHelper <CopyHelper>() .Draw(DeviceContextHolder, _shotRenderBuffer.View, _shotMsaaTemporaryTexture.TargetView); result = _shotMsaaTemporaryTexture; } else { result = _shotRenderBuffer; } if (Equals(downscale, 1d)) { Texture2D.ToStream(DeviceContext, result.Texture, format, outputStream); } else { DeviceContextHolder.GetHelper <DownsampleHelper>() .Draw(DeviceContextHolder, result, _shotDownsampleTexture, false); Texture2D.ToStream(DeviceContext, _shotDownsampleTexture.Texture, format, outputStream); } // Restoring old stuff _renderView = renderView; if (swapChainMode) { RecreateSwapChain(); } } ResolutionMultiplier = resolutionMultiplier; }