private void UpdateBlurredFlatMirror() { var use = FlatMirror && FlatMirrorBlurred; if (use == (_mirrorBuffer != null)) { return; } if (use) { _mirrorBuffer = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _mirrorBlurBuffer = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _temporaryBuffer = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _mirrorDepthBuffer = TargetResourceDepthTexture.Create(); if (!InitiallyResized) { return; } ResizeMirrorBuffers(); } else { DisposeHelper.Dispose(ref _mirrorBuffer); DisposeHelper.Dispose(ref _mirrorBlurBuffer); DisposeHelper.Dispose(ref _temporaryBuffer); DisposeHelper.Dispose(ref _mirrorDepthBuffer); } }
public void Draw(DeviceContextHolder holder, TargetResourceDepthTexture from, TargetResourceTexture to) { holder.DeviceContext.Rasterizer.SetViewports(to.Viewport); holder.DeviceContext.OutputMerger.SetTargets(to.TargetView); holder.PrepareQuad(_effect.LayoutPT); _effect.FxInputMap.SetResource(from.View); _effect.TechCopy.DrawAllPasses(holder.DeviceContext, 6); }
public ShadowsSpot(int mapSize) : base(mapSize) { _camera = new FpsCamera(1f) { NearZ = 0.02f }; _buffer = TargetResourceDepthTexture.Create(); }
public ShadowsPointFlat(int mapSize, float padding) : base(mapSize) { _cameras = Enumerable.Range(0, 6).Select(x => new FpsCamera(MathF.PI / 2) { NearZ = 0.1f, RhMode = false, CutProj = Matrix.Transformation2D(Vector2.Zero, 0f, new Vector2(padding), Vector2.Zero, 0f, Vector2.Zero) }).ToArray(); _buffer = TargetResourceDepthTexture.Create(Format.R24G8_Typeless); }
protected void FinalStep(TargetResourceTexture source, TargetResourceDepthTexture depth, float sizeMultiplier = 0.25f) { DeviceContext.OutputMerger.SetTargets(_outputBuffer.TargetView); DeviceContext.ClearRenderTargetView(_outputBuffer.TargetView, ColorTransparent); DeviceContextHolder.QuadBuffers.Prepare(DeviceContext, _ppBasic.LayoutPT); _ppBasic.FxScreenSize.Set(new Vector4(Width, Height, 1f / Width, 1f / Height)); _ppBasic.FxSizeMultipler.Set(sizeMultiplier); _ppBasic.FxInputMap.SetResource(source.View); _ppBasic.FxDepthMap.SetResource(depth.View); _ppBasic.TechDepth.DrawAllPasses(DeviceContext, 6); }
private void InitializeBuffers() { _shadowBuffer = TargetResourceDepthTexture.Create(); _bufferFSumm = TargetResourceTexture.Create(Format.R32G32B32A32_Float); _bufferF1 = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _bufferF2 = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _bufferA = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _summBlendState = Device.CreateBlendState(new RenderTargetBlendDescription { BlendEnable = true, SourceBlend = BlendOption.One, DestinationBlend = BlendOption.One, BlendOperation = BlendOperation.Add, SourceBlendAlpha = BlendOption.One, DestinationBlendAlpha = BlendOption.One, BlendOperationAlpha = BlendOperation.Add, RenderTargetWriteMask = ColorWriteMaskFlags.All, }); _bakedBlendState = Device.CreateBlendState(new RenderTargetBlendDescription { BlendEnable = true, SourceBlend = BlendOption.One, DestinationBlend = BlendOption.One, BlendOperation = BlendOperation.Maximum, SourceBlendAlpha = BlendOption.One, DestinationBlendAlpha = BlendOption.One, BlendOperationAlpha = BlendOperation.Maximum, RenderTargetWriteMask = ColorWriteMaskFlags.All, }); _effect = DeviceContextHolder.GetEffect <EffectSpecialShadow>(); _rasterizerStateFrontCull = RasterizerState.FromDescription(Device, new RasterizerStateDescription { CullMode = CullMode.Front, FillMode = FillMode.Solid, IsAntialiasedLineEnabled = false, IsDepthClipEnabled = true, DepthBias = (int)(100 * ShadowBiasCullFront), DepthBiasClamp = 0.0f, SlopeScaledDepthBias = ShadowBiasCullFront }); _rasterizerStateBackCull = RasterizerState.FromDescription(Device, new RasterizerStateDescription { CullMode = CullMode.Back, FillMode = FillMode.Solid, IsAntialiasedLineEnabled = false, IsDepthClipEnabled = true, DepthBias = (int)(100 * ShadowBiasCullBack), DepthBiasClamp = 0.0f, SlopeScaledDepthBias = ShadowBiasCullBack }); }
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); }
private void InitializeBuffers() { _shadowBuffer = TargetResourceDepthTexture.Create(); _summBuffer = TargetResourceTexture.Create(Format.R32_Float); _tempBuffer = TargetResourceTexture.Create(Format.R32_Float); _blendState = Device.CreateBlendState(new RenderTargetBlendDescription { BlendEnable = true, SourceBlend = BlendOption.One, DestinationBlend = BlendOption.One, BlendOperation = BlendOperation.Add, SourceBlendAlpha = BlendOption.SourceAlpha, DestinationBlendAlpha = BlendOption.InverseSourceAlpha, BlendOperationAlpha = BlendOperation.Add, RenderTargetWriteMask = ColorWriteMaskFlags.All, }); _effect = DeviceContextHolder.GetEffect <EffectSpecialShadow>(); }
protected override void InitializeInner() { _deferredLighting = DeviceContextHolder.GetEffect <EffectDeferredLight>(); _deferredResult = DeviceContextHolder.GetEffect <EffectDeferredResult>(); _ppBasic = DeviceContextHolder.GetEffect <EffectPpBasic>(); _gDepthBuffer = TargetResourceDepthTexture.Create(); _gBufferBase = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _gBufferNormal = TargetResourceTexture.Create(Format.R32G32B32A32_Float); _gBufferMaps = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _temporaryDepthBuffer = TargetResourceDepthTexture.Create(); _temporaryBuffer0 = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _temporaryBuffer1 = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _temporaryBuffer2 = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _temporaryBuffer3 = TargetResourceTexture.Create(Format.R16G16B16A16_Float); _outputBuffer = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm); _reflectionCubemap = new ReflectionCubemap(1024); _reflectionCubemap.Initialize(DeviceContextHolder); _sunShadows = new ShadowsDirectional(2048); _sunShadows.Initialize(DeviceContextHolder); }
public Split(float size, float clipDistance) { Buffer = TargetResourceDepthTexture.Create(); Update(size, clipDistance); }