private static void AddBatch(int counter, int offset, ISrvBindable prevTexture, MyTransparentMaterial prevMaterial) { MyBillboardRendererBatch batch = new MyBillboardRendererBatch(); batch.Offset = offset; batch.Num = counter - offset; batch.Texture = prevTexture; batch.Lit = prevMaterial.CanBeAffectedByOtherLights; batch.AlphaCutout = prevMaterial.AlphaCutout; m_batches.Add(batch); bool boundary = counter == m_billboardCountSafe || IsBucketBoundary(counter); if (boundary) { int currentBatchOffset = m_batches.Count; m_bucketBatches[GetBucketIndex(counter - 1)] = new MyBucketBatches { StartIndex = m_lastBatchOffset, Count = currentBatchOffset - m_lastBatchOffset }; m_lastBatchOffset = currentBatchOffset; } }
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(); }
private static void InitGatherList(int count, int countSafe) { int size = m_tempBuffer.Length; while (count > size) { size *= 2; } Array.Resize(ref m_tempBuffer, size); size = m_arrayDataBillboards.Length; while (countSafe > size) { size *= 2; } m_arrayDataBillboards.Resize(size); for (int i = 0; i < BUCKETS_COUNT; i++) { m_bucketBatches[i] = new MyBucketBatches(); } m_lastBatchOffset = 0; }