I've just spent the last 12 hours diving deep into my own personal fork of UnrealImGui trying to figure out why my embedded NetImGui application was failing, So im here to share what I found.
Under normal circumstances and in 99.9% of cases when ImGui outputs Command Buffers the Vtx Offset will always be zero, However theres a situation where you can store the information like this
Which in imguis internal rendering examples it takes VtxOffset into account and artifically adds 7 to all of the Idx's in the buffer between 7-13. Which would result in a draw call like
[a, b, c, d, e, f, g, H, I, J, K, L, M, N]
However in UnrealImGui's Application of this there is no such check for VtxOffset and it would actually render
[a, b, c, d, e, f, g, a, b, c, d, e, f, g]
What I did was modify the CopyIndexData implementation to accept a 4th VertexOffset value which does the appropriate offset
void FImGuiDrawList::CopyIndexData(TArray<SlateIndex>& OutIndexBuffer, const int32 StartIndex, const int32 NumElements, const int32 VertexOffset) const
{
// Reset buffer.
OutIndexBuffer.SetNumUninitialized(NumElements, false);
// Copy elements (slow copy because of different sizes of ImDrawIdx and SlateIndex and because SlateIndex can
// have different size on different platforms).
for (int i = 0; i < NumElements; i++)
{
OutIndexBuffer[i] = ImGuiIndexBuffer[StartIndex + i] + VertexOffset;
}
}
Feel free to do whatever implementation you want but as it currently operates things will not behave properly in nastily subtle ways that are a pain to track down
I've just spent the last 12 hours diving deep into my own personal fork of UnrealImGui trying to figure out why my embedded NetImGui application was failing, So im here to share what I found.
Under normal circumstances and in 99.9% of cases when ImGui outputs Command Buffers the Vtx Offset will always be zero, However theres a situation where you can store the information like this
Which in imguis internal rendering examples it takes VtxOffset into account and artifically adds 7 to all of the Idx's in the buffer between 7-13. Which would result in a draw call like
However in UnrealImGui's Application of this there is no such check for VtxOffset and it would actually render
What I did was modify the CopyIndexData implementation to accept a 4th VertexOffset value which does the appropriate offset
Modifying the call
As well as modifying the FImGuiDrawCommand
And The call that makes it inside of FImGuiDrawList
You can look at imgui_impl_dx11.cpp to see that this is meant to be handled
Feel free to do whatever implementation you want but as it currently operates things will not behave properly in nastily subtle ways that are a pain to track down