/// <summary>
        /// Render depth and normals of windows to the specified target
        /// REMARK: Only on the windows with decals
        /// </summary>
        /// <returns>True if windows to be rendered found</returns>
        internal static bool RenderWindowsDepthOnly(MyDepthStencil depthStencil, MyBindableResource gbuffer1)
        {
            if (m_windowCount == 0)
            {
                return(false);
            }

            TransferDataBillboards(WindowCountSafe, ref m_arrayDataWindows);

            RC.BindDepthRT(depthStencil, DepthStencilAccess.ReadWrite, gbuffer1);
            BindResourcesCommon();

            RC.SetBS(null);
            RC.SetVS(m_vsDepthOnly);
            RC.SetPS(m_psDepthOnly);


            if (!MyStereoRender.Enable)
            {
                RC.DeviceContext.DrawIndexed(m_windowCount * 6, 0, 0);
            }
            else
            {
                MyStereoRender.DrawIndexedBillboards(RC, m_windowCount * 6, 0, 0);
            }

            RC.SetRS(null);
            return(true);
        }
Esempio n. 2
0
        private static void Render(ISrvBindable depthRead, MyBucketBatches bucketBatches, bool oit)
        {
            if (!MyRender11.DebugOverrides.BillboardsDynamic && !MyRender11.DebugOverrides.BillboardsStatic)
            {
                return;
            }

            if (m_batches.Count == 0)
            {
                return;
            }

            MyRender11.GetRenderProfiler().StartProfilingBlock("Draw");

            RC.PixelShader.SetSrv(1, depthRead);
            BindResourcesCommon();

            PixelShaderFlags basePsFlags = (MyRender11.Settings.DisplayTransparencyHeatMap ? PixelShaderFlags.DEBUG_UNIFORM_ACCUM : 0) |
                                           ((MyRender11.DebugOverrides.OIT && oit) ? PixelShaderFlags.OIT : 0) |
                                           (depthRead != null ? PixelShaderFlags.SOFT_PARTICLE : 0);

            for (int i = bucketBatches.StartIndex; i < bucketBatches.StartIndex + bucketBatches.Count; i++)
            {
                var ps = m_psBundle[(int)(basePsFlags |
                                          (m_batches[i].Lit ? PixelShaderFlags.LIT_PARTICLE : 0) |
                                          (m_batches[i].AlphaCutout ? PixelShaderFlags.ALPHA_CUTOUT : 0))];
                RC.VertexShader.Set(m_batches[i].Lit ? m_vsLit : m_vs);
                RC.PixelShader.Set(ps);

                ISrvBindable texture = m_batches[i].Texture;
                RC.PixelShader.SetSrv(0, texture);
                if (!MyStereoRender.Enable)
                {
                    RC.DrawIndexed(m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                else
                {
                    MyStereoRender.DrawIndexedBillboards(RC, m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }

                IBorrowedRtvTexture borrowedTexture = texture as IBorrowedRtvTexture;
                if (borrowedTexture != null)
                {
                    borrowedTexture.Release();
                }

                MyStatsUpdater.Passes.DrawBillboards++;
            }

            m_stats.Billboards += m_billboardCountSafe;

            RC.SetRasterizerState(null);
            MyRender11.GatherPassStats(1298737, "Billboards", m_stats);
            MyRender11.GetRenderProfiler().EndProfilingBlock();
        }
Esempio n. 3
0
        /// <summary>Render depth and normals of windows to the specified target</summary>
        /// <returns>True if windows to be rendered found</returns>
        /// <param name="squaredDistanceMin">Squared distance internal minor</param>
        internal static bool RenderWindowsDepthOnly(IDepthStencil depthStencil, IRtvBindable gbuffer1,
                                                    float squaredDistanceMin, float squaredDistanceMax)
        {
            int offset          = 0;
            int windowsCount    = 0;
            int windowsCountMax = WindowCountSafe;

            for (int it = 0; it < windowsCountMax; it++)
            {
                // Interval is [min, max)
                MyBillboard billboard = m_sortedBuffer[m_sorteWindowIndices[it]];
                if (billboard.DistanceSquared >= squaredDistanceMax)
                {
                    break;
                }

                if (billboard.DistanceSquared < squaredDistanceMin)
                {
                    offset++;
                }
                else
                {
                    windowsCount++;
                }
            }

            if (windowsCount == 0)
            {
                return(false);
            }

            TransferDataBillboards(offset, windowsCount, ref m_arrayDataWindows);

            RC.SetRtv(depthStencil, MyDepthStencilAccess.ReadWrite, gbuffer1);
            BindResourcesCommon();

            RC.SetBlendState(null);
            RC.VertexShader.Set(m_vsDepthOnly);
            RC.PixelShader.Set(m_psDepthOnly);


            if (!MyStereoRender.Enable)
            {
                RC.DrawIndexed(m_windowCount * 6, 0, 0);
            }
            else
            {
                MyStereoRender.DrawIndexedBillboards(RC, m_windowCount * 6, 0, 0);
            }
            MyStatsUpdater.Passes.DrawBillboards++;

            RC.SetRasterizerState(null);
            return(true);
        }
Esempio n. 4
0
        internal unsafe static void Render(ISrvBindable depthRead)
        {
            if (!MyRender11.DebugOverrides.BillboardsDynamic && !MyRender11.DebugOverrides.BillboardsStatic)
            {
                return;
            }

            if (m_batches.Count == 0)
            {
                return;
            }

            MyRender11.GetRenderProfiler().StartProfilingBlock("Draw");
            TransferDataCustomProjections();
            TransferDataBillboards(0, BillboardCountSafe, ref m_arrayDataBillboards);

            RC.PixelShader.SetSrv(1, depthRead);
            BindResourcesCommon();

            for (int i = 0; i < m_batches.Count; i++)
            {
                // first part of batches contain sorted billboards and they read depth
                // second part of batches contain unsorted billboards and they ignore depth
                // switch here:
                if (m_batches[i].Offset == m_sortedCount)
                {
                    //RC.BindDepthRT(null, DepthStencilAccess.ReadOnly, dst);
                }

                if (MyRender11.Settings.DisplayTransparencyHeatMap)
                {
                    RC.VertexShader.Set(m_vs);
                    RC.PixelShader.Set(MyRender11.DebugOverrides.OIT ? m_psDebugUniformAccumOIT : m_psDebugUniformAccum);
                }
                else if (m_batches[i].Lit)
                {
                    RC.VertexShader.Set(m_vsLit);

                    if (m_batches[i].AlphaCutout)
                    {
                        RC.PixelShader.Set(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutAndLitOIT : m_psAlphaCutoutAndLit);
                    }
                    else
                    {
                        RC.PixelShader.Set(MyRender11.DebugOverrides.OIT ? m_psLitOIT : m_psLit);
                    }
                }
                else if (m_batches[i].AlphaCutout)
                {
                    RC.VertexShader.Set(m_vs);
                    RC.PixelShader.Set(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutOIT : m_psAlphaCutout);
                }
                else
                {
                    RC.VertexShader.Set(m_vs);
                    RC.PixelShader.Set(MyRender11.DebugOverrides.OIT ? m_psOIT : m_ps);
                }

                ISrvBindable texture = m_batches[i].Texture;
                RC.PixelShader.SetSrv(0, texture);
                if (!MyStereoRender.Enable)
                {
                    RC.DrawIndexed(m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                else
                {
                    MyStereoRender.DrawIndexedBillboards(RC, m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }

                IBorrowedRtvTexture borrowedTexture = texture as IBorrowedRtvTexture;
                if (borrowedTexture != null)
                {
                    borrowedTexture.Release();
                }

                MyStatsUpdater.Passes.DrawBillboards++;
            }

            m_stats.Billboards += BillboardCountSafe;

            RC.SetRasterizerState(null);
            MyRender11.GatherStats(m_stats);
            MyRender11.GetRenderProfiler().EndProfilingBlock();
        }
        internal unsafe static void Render(MyBindableResource depthRead)
        {
            if (!MyRender11.DebugOverrides.BillboardsDynamic && !MyRender11.DebugOverrides.BillboardsStatic)
            {
                return;
            }

            m_stats.Clear();

            MyRender11.GetRenderProfiler().StartProfilingBlock("Gather");
            Gather();
            MyRender11.GetRenderProfiler().EndProfilingBlock();

            if (m_batches.Count == 0)
            {
                return;
            }

            MyRender11.GetRenderProfiler().StartProfilingBlock("Draw");
            TransferDataCustomProjections();
            TransferDataBillboards(BillboardCountSafe, ref m_arrayDataBillboards);

            RC.BindSRV(1, depthRead);
            BindResourcesCommon();

            for (int i = 0; i < m_batches.Count; i++)
            {
                // first part of batches contain sorted billboards and they read depth
                // second part of batches contain unsorted billboards and they ignore depth
                // switch here:
                if (m_batches[i].Offset == m_sortedCount)
                {
                    //RC.BindDepthRT(null, DepthStencilAccess.ReadOnly, dst);
                }

                if (m_batches[i].Lit)
                {
                    RC.SetVS(m_vsLit);

                    if (m_batches[i].AlphaCutout)
                    {
                        RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutAndLitOIT : m_psAlphaCutoutAndLit);
                    }
                    else
                    {
                        RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psLitOIT : m_psLit);
                    }
                }
                else if (m_batches[i].AlphaCutout)
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutOIT : m_psAlphaCutout);
                }
                else
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psOIT : m_ps);
                }

                RC.BindRawSRV(0, m_batches[i].Texture);
                if (!MyStereoRender.Enable)
                {
                    RC.DeviceContext.DrawIndexed(m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                else
                {
                    MyStereoRender.DrawIndexedBillboards(RC, m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                ++RC.Stats.BillboardDrawIndexed;
            }

            m_stats.Billboards += BillboardCountSafe;

            RC.SetRS(null);
            MyRender11.GatherStats(m_stats);
            MyRender11.GetRenderProfiler().EndProfilingBlock();
        }