'Actorless rendering' with GPU Instancing

Unity engine supports user GameObject-less GPU Instancing by DrawMeshInstanced series API. It provides some ways to make pure draw calls without generating loads of objects, so basically it is for “DIYer’s own ECS system” and helps to overcome the limit of Unity’s own pipeline performance ceiling without the messiness of DOTS hell.

I saw DrawInstanced(Indirect) series API methods in FlaxEngine.GPUContext, but it seems like just a wrapper of backend render systems’ API. As referring the code of engine renderer core, calling Flax’s DrawInstanced API requires a bunch of backend renderer context setup, so it seems not that easy to ‘just draw the buffer now’ like that in Unity.

I hope that there may be the way for user to use GPU Instancing in Flax in someday, or some example/manuals to be added if it is already configurable.

Use can call Mesh.Draw with a custom transformation (and options) during scene rendering events to submit draw calls into rendering layer - Flax will automatically perform batching. Class Mesh | Flax Documentation

If you want you can do manuall draw calls submission via mentioned API but this will require accessing Vertex/Index buffers of the mesh and material setup. Some more docs: Custom Geometry Drawing | Flax Documentation

1 Like

I thought Mesh.Draw is not much designed for performance purpose, so how is the overhead compared to the actor render(batched)?

And about the GPUContext’s draw api (custom geometry drawing), I understood your explanations that it can be used by user as the form of PostProcessEffect, which means that it is deferred rendering(separated pass in pipeline), is it right?

If you call Mesh.Draw manually you don’t pay the overhead of actor objects allocation and related processing so it will be faster.

The fastest way of drawing lots of stuff (instanced models) using the high-level API is via DrawCallsLists which is used by Foliage: https://github.com/FlaxEngine/FlaxEngine/blob/master/Source/Engine/Foliage/Foliage.cpp#L415 It runs in async during scene rendering and calls each foliage type (model type) for all instances at once via a single draw call that is automatically batched.

Regarding PostProcessEffect you can set Location field to eg. to PostProcessEffectLocation.AfterGBufferPass to draw stuff after GBuffer is filled but before any lighting.