Fix custom GUI material writing depth when it's not needed

#3294
This commit is contained in:
Wojtek Figat
2025-03-18 10:57:12 +01:00
parent e25efa8c6f
commit 68967de1f5
4 changed files with 15 additions and 18 deletions

View File

@@ -759,10 +759,7 @@ void Render2D::End()
IsScissorsRectEmpty = false;
for (int32 i = 0; i < DrawCalls.Count(); i++)
{
// Peek draw call
const auto& drawCall = DrawCalls[i];
// Check if cannot add element to the batching
if (batchSize != 0 && !CanBatchDrawCalls(DrawCalls[batchStart], drawCall))
{
// Flush batched elements
@@ -990,6 +987,7 @@ void DrawBatch(int32 startIndex, int32 count)
Render2D::CustomData customData;
customData.ViewProjection = ViewProjection;
customData.ViewSize = Float2::One;
customData.UseDepthBuffer = DepthBuffer != nullptr;
bindParams.CustomData = &customData;
material->Bind(bindParams);
@@ -1026,6 +1024,7 @@ void DrawBatch(int32 startIndex, int32 count)
Render2D::CustomData customData;
customData.ViewProjection = ViewProjection;
customData.ViewSize = Float2(d.AsMaterial.Width, d.AsMaterial.Height);
customData.UseDepthBuffer = DepthBuffer != nullptr;
bindParams.CustomData = &customData;
material->Bind(bindParams);

View File

@@ -55,6 +55,7 @@ API_CLASS(Static) class FLAXENGINE_API Render2D
{
Matrix ViewProjection;
Float2 ViewSize;
bool UseDepthBuffer;
};
public: