public void Initialize(D3D11RenderBackend backend) { RenderBackend = backend; if (RT2D == null) { return; } m_HistoryColorBrush = ToDispose(new SolidColorBrush(RT2D, Color.White)); m_ErrorColorBrush = ToDispose(new SolidColorBrush(RT2D, Color.Red)); m_CommandColorBrush = ToDispose(new SolidColorBrush(RT2D, Color.Yellow)); m_TextFormat = ToDispose(new TextFormat(FactoryDWrite, "Roboto", 15) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Near }); m_FPSTextFormat = ToDispose(new TextFormat(FactoryDWrite, "Roboto", 20) { TextAlignment = TextAlignment.Trailing, ParagraphAlignment = ParagraphAlignment.Near }); m_RectangleGeometry = ToDispose(new RoundedRectangleGeometry(RenderBackend.DisplayRef.Factory2D, new RoundedRectangle() { RadiusX = 0, RadiusY = 0, Rect = new RectangleF(0, 0, 500, 1200) })); m_TextLayout = ToDispose(new TextLayout(FactoryDWrite, "", m_TextFormat, 500, 20)); m_HistoryTextLayout = ToDispose(new TextLayout(FactoryDWrite, "", m_TextFormat, 500, 200)); m_CaretTextLayout = ToDispose(new TextLayout(FactoryDWrite, "", m_TextFormat, 500, 20)); m_SolidColorBrush = ToDispose(new SolidColorBrush(RT2D, new Color(new Vector4(0.7f, 0.7f, 0.7f, 0.6f)))); m_FPSTextLayout = ToDispose(new TextLayout(FactoryDWrite, "", m_FPSTextFormat, 100, 100)); }
public override void Init(D3D11RenderBackend renderBackend) { base.Init(renderBackend); InitShadersNames(); InitGBuffer(MSSamplesCount); CreateBuffers(); ScriptEngine.TestRef = this; }
public override void Init(D3D11RenderBackend renderBackend) { postProcessSettings = new PostProcessSettings() { MotionBlurEnabled = false, }; base.Init(renderBackend); int samples = 1; switch (renderBackend.EngineRef.CurrentConfig.EnableMSAA) { case Engine.EngineConfiguration.MSAAEnabled.x4: samples = 4; break; case Engine.EngineConfiguration.MSAAEnabled.x8: samples = 8; break; } InitTargets(samples); CreateBuffers(); }
public override void Init(D3D11RenderBackend backend) { base.Init(backend); // Create shaders and layouts. AssetsLoader.GetShader <VertexShader>("ScreenQuadVS", out ShaderSignature vsSignature); QuadLayoyt = new InputLayout(RenderBackend.Device, vsSignature, new InputElement[] { new InputElement("SV_VertexID", 0, Format.R32G32B32_Float, 0, 0), }); AssetsLoader.GetShader <VertexShader>("ForwardPlusPosOnlyVS", out vsSignature); DepthPassLayout = new InputLayout(RenderBackend.Device, vsSignature, new InputElement[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), new InputElement("TEXCOORD", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), new InputElement("TEXCOORD", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), new InputElement("TANGENT", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0), }); //Create constant buffer PerObjConstantBuffer = new Buffer( RenderBackend.Device, Utilities.SizeOf <CommonStructs.ConstBufferPerObjectStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0 ); PerFrameConstantBuffer = new Buffer( RenderBackend.Device, Utilities.SizeOf <CommonStructs.ConstBufferPerFrameStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0 ); m_LightBuffer = new LightBufferStruct[] { new LightBufferStruct(), new LightBufferStruct(), new LightBufferStruct() }; LightBuffer = new Buffer( RenderBackend.Device, Utilities.SizeOf <LightBufferStruct>() * m_LightBuffer.Length, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0 ); ScreenParameters = new Buffer( RenderBackend.Device, Utilities.SizeOf <ScreenParametersStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0 ); GetContext.VertexShader.SetConstantBuffer(0, PerObjConstantBuffer); GetContext.VertexShader.SetConstantBuffer(1, PerFrameConstantBuffer); GetContext.VertexShader.SetConstantBuffer(2, LightBuffer); GetContext.PixelShader.SetConstantBuffer(0, PerObjConstantBuffer); GetContext.PixelShader.SetConstantBuffer(1, PerFrameConstantBuffer); GetContext.PixelShader.SetConstantBuffer(2, LightBuffer); Texture2DDescription textureDescription = new Texture2DDescription() { Width = RenderBackend.DisplayRef.Width, Height = RenderBackend.DisplayRef.Height, MipLevels = 1, ArraySize = 1, Format = Format.R16G16_Float, SampleDescription = new SampleDescription() { Count = 1, }, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, }; RenderTargetViewDescription renderTargetDescription = new RenderTargetViewDescription() { Format = Format.R16G16_Float, Dimension = RenderTargetViewDimension.Texture2D, }; ShaderResourceViewDescription shaderResourceDescription = new ShaderResourceViewDescription() { Format = Format.R16G16_Float, Dimension = ShaderResourceViewDimension.Texture2D, }; shaderResourceDescription.Texture2D.MostDetailedMip = 0; shaderResourceDescription.Texture2D.MipLevels = 1; textureTarget = new Texture2D(RenderBackend.Device, textureDescription); velocityRenderTargetView = new RenderTargetView(RenderBackend.Device, textureTarget, renderTargetDescription); velocitySRV = new ShaderResourceView(RenderBackend.Device, textureTarget, shaderResourceDescription); textureDescription.Format = m_HDRformar; renderTargetDescription.Format = m_HDRformar; shaderResourceDescription = new ShaderResourceViewDescription() { Format = m_HDRformar, Dimension = ShaderResourceViewDimension.Texture2D, }; shaderResourceDescription.Texture2D.MostDetailedMip = 0; shaderResourceDescription.Texture2D.MipLevels = 1; hdrTextureTarget = new Texture2D(RenderBackend.Device, textureDescription); hdrSRV = new ShaderResourceView(RenderBackend.Device, hdrTextureTarget, shaderResourceDescription); hdrRenderTargetView = new RenderTargetView(RenderBackend.Device, hdrTextureTarget, renderTargetDescription); textureDescription.Width = textureDescription.Width / 4; textureDescription.Height = textureDescription.Height / 4; downSamplingTarget = new Texture2D(RenderBackend.Device, textureDescription); downSamplingSRV = new ShaderResourceView(RenderBackend.Device, downSamplingTarget, shaderResourceDescription); downSamplingTargetView = new RenderTargetView(RenderBackend.Device, downSamplingTarget, renderTargetDescription); }
public override void Init(D3D11RenderBackend renderBackend) { base.Init(renderBackend); // Create constant buffers BufferDescription bufferDescription = new BufferDescription() { SizeInBytes = Utilities.SizeOf <CommonStructs.ConstBufferPerObjectStruct>(), Usage = ResourceUsage.Default, BindFlags = BindFlags.ConstantBuffer, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, StructureByteStride = 0, }; PerObjConstantBuffer = new Buffer(GetDevice, bufferDescription); bufferDescription.SizeInBytes = Utilities.SizeOf <CommonStructs.ConstBufferPerFrameStruct>(); PerFrameConstantBuffer = new Buffer(GetDevice, bufferDescription); // Bind constant buffers GetContext.VertexShader.SetConstantBuffer(0, PerObjConstantBuffer); GetContext.VertexShader.SetConstantBuffer(1, PerFrameConstantBuffer); GetContext.PixelShader.SetConstantBuffer(0, PerObjConstantBuffer); GetContext.PixelShader.SetConstantBuffer(1, PerFrameConstantBuffer); InitLightsBuffers(); Texture2DDescription textureDescription = new Texture2DDescription() { Width = GetDisplay.Width, Height = GetDisplay.Height, MipLevels = 1, ArraySize = 1, Format = Format.R16G16_Float, SampleDescription = new SampleDescription() { Count = 1, }, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, }; RenderTargetViewDescription renderTargetDescription = new RenderTargetViewDescription() { Format = Format.R16G16_Float, Dimension = RenderTargetViewDimension.Texture2D, }; ShaderResourceViewDescription shaderResourceDescription = new ShaderResourceViewDescription() { Format = Format.R16G16_Float, Dimension = ShaderResourceViewDimension.Texture2D, }; shaderResourceDescription.Texture2D.MostDetailedMip = 0; shaderResourceDescription.Texture2D.MipLevels = 1; textureDescription.Format = m_HDRformar; renderTargetDescription.Format = m_HDRformar; shaderResourceDescription = new ShaderResourceViewDescription() { Format = m_HDRformar, Dimension = ShaderResourceViewDimension.Texture2D, }; shaderResourceDescription.Texture2D.MostDetailedMip = 0; shaderResourceDescription.Texture2D.MipLevels = 1; hdrTextureTarget = new Texture2D(GetDevice, textureDescription); hdrSRV = new ShaderResourceView(GetDevice, hdrTextureTarget, shaderResourceDescription); hdrRenderTargetView = new RenderTargetView(GetDevice, hdrTextureTarget, renderTargetDescription); }