예제 #1
0
        internal static void Run(IRtvBindable dst, MyGBuffer gbuffer, ISrvBindable resolvedDepth)
        {
            RC.ClearRtv(dst, new SharpDX.Color4(1, 1, 1, 1));

            var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2));

            var mapping = MyMapping.MapDiscard(paramsCB);

            mapping.WriteAndPosition(ref Params.Data);
            FillRandomVectors(mapping);
            mapping.Unmap();

            if (!MyStereoRender.Enable)
            {
                RC.AllShaderStages.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            }
            else
            {
                MyStereoRender.BindRawCB_FrameConstants(RC);
            }
            RC.AllShaderStages.SetConstantBuffer(1, paramsCB);

            RC.PixelShader.Set(m_ps);
            RC.SetRtv(dst);

            RC.PixelShader.SetSrvs(0, gbuffer);
            RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers);
            RC.PixelShader.SetSrv(5, resolvedDepth);
            RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil);

            DrawFullscreenQuad();
            RC.ResetTargets();
        }
예제 #2
0
        internal static void Run(MyBindableResource dst, MyGBuffer gbuffer, MyBindableResource resolvedDepth)
        {
            RC.DeviceContext.ClearRenderTargetView((dst as IRenderTargetBindable).RTV, new SharpDX.Color4(1, 1, 1, 1));

            var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2));

            var mapping = MyMapping.MapDiscard(paramsCB);

            mapping.WriteAndPosition(ref Params);
            FillRandomVectors(mapping);
            mapping.Unmap();

            if (!MyStereoRender.Enable)
            {
                RC.SetCB(0, MyCommon.FrameConstants);
            }
            else
            {
                MyStereoRender.BindRawCB_FrameConstants(RC);
            }
            RC.SetCB(1, paramsCB);

            RC.SetPS(m_ps);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst);

            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, resolvedDepth);

            DrawFullscreenQuad();
        }
예제 #3
0
        /// <summary>
        /// Bind the provided slot to SV_Target0. Useful for dual-source blending
        /// </summary>
        internal void BindGBufferForWrite(MyGBuffer gbuffer, MyGbufferSlot slot, DepthStencilAccess depthStencilFlags = DepthStencilAccess.ReadWrite)
        {
            m_tmpBinds1[0] = gbuffer.Get(slot);
            BindDepthRTInternal(gbuffer.Get(MyGbufferSlot.DepthStencil), depthStencilFlags, m_tmpBinds1);

            Array.Clear(m_tmpBinds1, 0, m_tmpBinds1.Length);
        }
예제 #4
0
        internal static void Run(MyBindableResource dst, MyGBuffer gbuffer, MyBindableResource resolvedDepth)
        {
            RC.Context.ClearRenderTargetView((dst as IRenderTargetBindable).RTV, new SharpDX.Color4(1, 1, 1, 1));

            var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2));

            var mapping = MyMapping.MapDiscard(paramsCB);

            mapping.stream.Write(Params.MinRadius);
            mapping.stream.Write(Params.MaxRadius);
            mapping.stream.Write(Params.RadiusGrow);
            mapping.stream.Write(Params.Falloff);
            mapping.stream.Write(Params.RadiusBias);
            mapping.stream.Write(Params.Contrast);
            mapping.stream.Write(Params.Normalization);
            mapping.stream.Write(0);
            FillRandomVectors(mapping.stream);
            mapping.Unmap();

            RC.SetCB(0, MyCommon.FrameConstants);
            RC.SetCB(1, paramsCB);

            RC.SetPS(m_ps);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst);

            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, resolvedDepth);

            DrawFullscreenQuad();
        }
예제 #5
0
 internal void BindGBufferForWrite(MyGBuffer gbuffer)
 {
     BindDepthRT(
         gbuffer.Get(MyGbufferSlot.DepthStencil), DepthStencilAccess.ReadWrite,
         gbuffer.Get(MyGbufferSlot.GBuffer0),
         gbuffer.Get(MyGbufferSlot.GBuffer1),
         gbuffer.Get(MyGbufferSlot.GBuffer2));
 }
예제 #6
0
 internal void BindGBufferForReadSkipStencil(int slot, MyGBuffer gbuffer)
 {
     BindSRV(slot,
             gbuffer.DepthStencil.Depth,
             gbuffer.Get(MyGbufferSlot.GBuffer0),
             gbuffer.Get(MyGbufferSlot.GBuffer1),
             gbuffer.Get(MyGbufferSlot.GBuffer2));
 }
예제 #7
0
        internal void BindGBufferForWrite(MyGBuffer gbuffer, DepthStencilAccess depthStencilFlags = DepthStencilAccess.ReadWrite)
        {
            m_tmpBinds3[0] = gbuffer.Get(MyGbufferSlot.GBuffer0);
            m_tmpBinds3[1] = gbuffer.Get(MyGbufferSlot.GBuffer1);
            m_tmpBinds3[2] = gbuffer.Get(MyGbufferSlot.GBuffer2);
            BindDepthRTInternal(gbuffer.Get(MyGbufferSlot.DepthStencil), depthStencilFlags, m_tmpBinds3);

            Array.Clear(m_tmpBinds3, 0, m_tmpBinds3.Length);
        }
예제 #8
0
        internal void BindGBufferForReadSkipStencil(int slot, MyGBuffer gbuffer)
        {
            m_tmpBinds4[0] = gbuffer.DepthStencil.Depth;
            m_tmpBinds4[1] = gbuffer.Get(MyGbufferSlot.GBuffer0);
            m_tmpBinds4[2] = gbuffer.Get(MyGbufferSlot.GBuffer1);
            m_tmpBinds4[3] = gbuffer.Get(MyGbufferSlot.GBuffer2);
            BindSRVsInternal(slot, m_tmpBinds4);

            Array.Clear(m_tmpBinds4, 0, m_tmpBinds4.Length);
        }
예제 #9
0
        internal void BindGBufferForRead(int slot, MyGBuffer gbuffer)
        {
            m_tmpBinds5[0] = gbuffer.DepthStencil.Depth;
            m_tmpBinds5[1] = gbuffer.Get(MyGbufferSlot.GBuffer0);
            m_tmpBinds5[2] = gbuffer.Get(MyGbufferSlot.GBuffer1);
            m_tmpBinds5[3] = gbuffer.Get(MyGbufferSlot.GBuffer2);
            m_tmpBinds5[4] = gbuffer.DepthStencil.Stencil;
            BindSRVsInternal(slot, m_tmpBinds5);

            Array.Clear(m_tmpBinds5, 0, m_tmpBinds5.Length);
        }
예제 #10
0
        internal void AddMainViewPass(MyViewport viewport, MyGBuffer gbuffer)
        {
            int frustumMask = AddFrustum(ref MyRender11.Environment.ViewProjectionD);

            FrustumCullQueries[Size - 1].Type = MyFrustumEnum.MainFrustum;

            var pass = MyObjectPoolManager.Allocate <MyGBufferPass>();

            pass.ProcessingMask = frustumMask;
            pass.ViewProjection = MyRender11.Environment.ViewProjectionAt0;
            pass.Viewport       = viewport;
            pass.GBuffer        = gbuffer;

            pass.PerFrame();

            RenderingPasses[Size - 1] = pass;
        }
예제 #11
0
        internal static void Run(IRtvTexture dst, MyGBuffer gbuffer, ISrvBindable resolvedDepth, MyViewport?viewport = null)
        {
            CompilePS();

            if (!viewport.HasValue)
            {
                viewport = new MyViewport(0, 0, MyRender11.m_resolution.X, MyRender11.m_resolution.Y);
            }
            var data = InitConstantBuffer(viewport.Value);

            var mapping = MyMapping.MapDiscard(m_dataCB);

            mapping.WriteAndPosition(ref data);
            mapping.Unmap();
            RC.PixelShader.SetConstantBuffer(0, m_dataCB);

            RC.PixelShader.SetSamplers(0, MySamplerStateManager.PointHBAOClamp);
            RC.SetBlendState(null);

            DrawLinearDepthPS(resolvedDepth, m_fullResViewDepthTarget, viewport.Value);

            DrawDeinterleavedDepth(viewport.Value);

            DrawCoarseAO(gbuffer, viewport.Value);

            if (Params.BlurEnable)
            {
                Resolve(true, m_fullResAOZTexture2, viewport.Value);

                DrawBlurXPS(viewport.Value);
                DrawBlurYPS(dst, viewport.Value);
            }
            else
            {
                Resolve(false, dst, viewport.Value);
            }

            RC.SetRtv(null);
        }
예제 #12
0
        static void DrawCoarseAO(MyGBuffer gbuffer, MyViewport viewport)
        {
            var qViewport = GetQuarterViewport(viewport);

            RC.PixelShader.Set(m_coarseAOPS);
            RC.PixelShader.SetSamplers(0, Params.DepthClampToEdge ? MySamplerStateManager.PointHBAOClamp : MySamplerStateManager.PointHBAOBorder);
            RC.PixelShader.SetSamplers(1, MySamplerStateManager.PointHBAOClamp);
            RC.PixelShader.SetSrv(1, gbuffer.GBuffer1);

            for (int sliceIndex = 0; sliceIndex < NUM_SLICES; ++sliceIndex)
            {
                RC.PixelShader.SetSrv(0, m_quarterResViewDepthTextureArray.SubresourceSrv(sliceIndex));

                RC.PixelShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]);
                RC.GeometryShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]);

                RC.SetRtv(m_quarterResAOTextureArray.SubresourceRtv(sliceIndex));
                MyScreenPass.DrawFullscreenQuad(qViewport);
            }

            RC.GeometryShader.Set(null);
        }
        internal static void Run(MyBindableResource dst1, MyBindableResource dst2, MyBindableResource lightBuffer, MyGBuffer gbuffer)
        {
            if (!Settings.BlurEnabled || Settings.BlurAmount < 0.01f)
            {
                return;
            }

            RC.DeviceContext.ClearRenderTargetView((dst1 as IRenderTargetBindable).RTV, new SharpDX.Color4(0, 0, 0, 0));
            RC.DeviceContext.ClearRenderTargetView((dst2 as IRenderTargetBindable).RTV, new SharpDX.Color4(0, 0, 0, 0));

            float zero = 0f;
            var mapping = MyMapping.MapDiscard(m_cb);
            mapping.WriteAndPosition(ref Settings.BlurAmount);
            mapping.WriteAndPosition(ref Settings.BlurDistance);
            mapping.WriteAndPosition(ref Settings.BlurTransitionRatio);
            mapping.WriteAndPosition(ref zero);
            mapping.Unmap();

            RC.SetCB(0, MyCommon.FrameConstants);
            RC.SetCB(1, m_cb);
            

            RC.SetPS(m_psH);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst1);
            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, lightBuffer);
            DrawFullscreenQuad();


            RC.SetPS(m_psV);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst2);
            RC.BindSRV(5, dst1);

            DrawFullscreenQuad();

//          MyBlendTargets.Run(lightBuffer, MyScreenDependants.m_planetBlur2, MyRender11.BlendPlanetBlur);
//          MyBlendTargets.Run(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer), MyScreenDependants.m_planetBlur2, MyRender11.BlendPlanetBlur);
        }
예제 #14
0
        internal static void Run(MyBindableResource dst1, MyBindableResource dst2, MyBindableResource lightBuffer, MyGBuffer gbuffer)
        {
            if (!Settings.BlurEnabled || Settings.BlurAmount < 0.01f)
            {
                return;
            }

            RC.DeviceContext.ClearRenderTargetView((dst1 as IRenderTargetBindable).RTV, new SharpDX.Color4(0, 0, 0, 0));
            RC.DeviceContext.ClearRenderTargetView((dst2 as IRenderTargetBindable).RTV, new SharpDX.Color4(0, 0, 0, 0));

            float zero    = 0f;
            var   mapping = MyMapping.MapDiscard(m_cb);

            mapping.WriteAndPosition(ref Settings.BlurAmount);
            mapping.WriteAndPosition(ref Settings.BlurDistance);
            mapping.WriteAndPosition(ref Settings.BlurTransitionRatio);
            mapping.WriteAndPosition(ref zero);
            mapping.Unmap();

            RC.SetCB(0, MyCommon.FrameConstants);
            RC.SetCB(1, m_cb);


            RC.SetPS(m_psH);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst1);
            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, lightBuffer);
            DrawFullscreenQuad();


            RC.SetPS(m_psV);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst2);
            RC.BindSRV(5, dst1);

            DrawFullscreenQuad();

//          MyBlendTargets.Run(lightBuffer, MyScreenDependants.m_planetBlur2, MyRender11.BlendPlanetBlur);
//          MyBlendTargets.Run(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer), MyScreenDependants.m_planetBlur2, MyRender11.BlendPlanetBlur);
        }
예제 #15
0
        internal static void Run(MyBindableResource dst, MyGBuffer gbuffer, MyBindableResource resolvedDepth)
        {
            RC.Context.ClearRenderTargetView((dst as IRenderTargetBindable).RTV, new SharpDX.Color4(1, 1, 1, 1));

            var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2));

            var mapping = MyMapping.MapDiscard(paramsCB);
            mapping.stream.Write(Params.MinRadius);
            mapping.stream.Write(Params.MaxRadius);
            mapping.stream.Write(Params.RadiusGrow);
            mapping.stream.Write(Params.Falloff);
            mapping.stream.Write(Params.RadiusBias);
            mapping.stream.Write(Params.Contrast);
            mapping.stream.Write(Params.Normalization);
            mapping.stream.Write(0);
            FillRandomVectors(mapping.stream);
            mapping.Unmap();

            RC.SetCB(0, MyCommon.FrameConstants);
            RC.SetCB(1, paramsCB);

            RC.SetPS(m_ps);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst);

            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, resolvedDepth);

            DrawFullscreenQuad();
        }
예제 #16
0
        internal static void AddCamera(ref MatrixD viewMatrix, ref MatrixD projectionMatrix, MyViewport viewport, MyGBuffer gbuffer)
        {
            var frustumMask = m_cullQuery.AddFrustum(new BoundingFrustumD(MyEnvironment.ViewProjectionD));

            MyGBufferPass pass = new MyGBufferPass();

            pass.Cleanup();
            pass.ProcessingMask = frustumMask;
            pass.ViewProjection = MyEnvironment.ViewProjectionAt0;
            pass.Viewport       = viewport;
            pass.GBuffer        = gbuffer;

            pass.PerFrame();

            m_wavefront.Add(pass);
        }
예제 #17
0
 internal override void Cleanup()
 {
     base.Cleanup();
     GBuffer = null;
 }
        internal void AddMainViewPass(MyViewport viewport, MyGBuffer gbuffer)
        {
            int frustumMask = AddFrustum(ref MyRender11.Environment.ViewProjectionD);
            FrustumCullQueries[Size - 1].Type = MyFrustumEnum.MainFrustum;

            var pass = MyObjectPoolManager.Allocate<MyGBufferPass>();
            pass.ProcessingMask = frustumMask;
            pass.ViewProjection = MyRender11.Environment.ViewProjectionAt0;
            pass.Viewport = viewport;
            pass.GBuffer = gbuffer;

            pass.PerFrame();

            RenderingPasses[Size - 1] = pass;
        }
예제 #19
0
 internal void BindGBufferForReadSkipStencil(int slot, MyGBuffer gbuffer)
 {
     BindSRV(slot,
         gbuffer.DepthStencil.Depth,
         gbuffer.Get(MyGbufferSlot.GBuffer0),
         gbuffer.Get(MyGbufferSlot.GBuffer1),
         gbuffer.Get(MyGbufferSlot.GBuffer2));
 }
예제 #20
0
 internal void BindGBufferForWrite(MyGBuffer gbuffer)
 {
     BindDepthRT(
         gbuffer.Get(MyGbufferSlot.DepthStencil), DepthStencilAccess.ReadWrite,
         gbuffer.Get(MyGbufferSlot.GBuffer0),
         gbuffer.Get(MyGbufferSlot.GBuffer1),
         gbuffer.Get(MyGbufferSlot.GBuffer2));
 }
 internal override void Cleanup()
 {
     base.Cleanup();
     GBuffer = null;
 }
예제 #22
0
        internal static void Run(MyBindableResource dst, MyGBuffer gbuffer, MyBindableResource resolvedDepth)
        {
            RC.DeviceContext.ClearRenderTargetView((dst as IRenderTargetBindable).RTV, new SharpDX.Color4(1, 1, 1, 1));

            var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2));

            var mapping = MyMapping.MapDiscard(paramsCB);
            mapping.WriteAndPosition(ref Params);
            FillRandomVectors(mapping);
            mapping.Unmap();

            if (!MyStereoRender.Enable)
                RC.SetCB(0, MyCommon.FrameConstants);
            else
                MyStereoRender.BindRawCB_FrameConstants(RC);
            RC.SetCB(1, paramsCB);

            RC.SetPS(m_ps);
            RC.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, dst);

            RC.BindGBufferForRead(0, gbuffer);
            RC.BindSRV(5, resolvedDepth);

            DrawFullscreenQuad();
        }