Announcement

Collapse
No announcement yet.

Instanced Rendering

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Thanks for the explanation Daniel, that makes sense.

    Leave a comment:


  • replied
    Sadly the term 'instancing' is being used in two ways in UE4.

    Instancing of components like UStaticMeshComponent: this means the components are all sharing the same *resource*, which is the UStaticMesh vertex and index data. This saves memory. As far as draw calls go, each element of a UStaticMeshComponent will issue a draw call in each mesh pass it is in (depth only, base pass, shadow depth pass, etc). Even though every element of every instance/component is a draw call, there's a lot less state setup for UStaticMeshComponent's of the same mesh and material and they can cost ~3x less than if every UStaticMeshComponent had a different mesh and material.

    Instancing as in UInstancedStaticMeshComponent: this is referring to *hardware* instancing, which is the GPU feature that you issue one draw call and a bunch of per-instance work is done in the vertex shader. It typically reduces rendering thread overhead, but increases GPU vertex cost and has a very limited feature set, because any per-instance features (all the rendering flags on UPrimitiveComponent) have to be done in the vertex shader. By rendering meshes with low poly counts, you can get huge performance savings with this. UE4 does not yet support lightmaps on UInstancedStaticMeshComponent, but they are coming.

    Leave a comment:


  • replied
    Originally posted by Stefan Lundmark View Post
    You can call it whatever you want and I'm well aware of batching, but Epic calls it instancing in their tools:



    and that's what we're all (presumably) using and discussing. It's quite clear which one of the two that the OP was asking about, too.

    No, that's foliage, and the OP wasn't asking about foliage. Foliage is batched because otherwise you wouldn't be able to do it. If you placed the foliage by hand instead of using the foliage system then it wouldn't be batched and you would have a significantly lower performance. You could batch things together and it will reduce the draw calls, and if they are simple objects then they won't be much of a strain, but you wouldn't be able to do that with everything.

    Leave a comment:


  • replied
    So are instanced meshes batched or not?

    My assumption would be yes, as there doesn't seem to be a whole lot of point otherwise, and it's also a very common engine feature in modern engines.

    Leave a comment:


  • replied
    Originally posted by darthviper107 View Post
    Instancing doesn't reduce drawcalls, if you're talking about batching, then like the post before yours then that's something different.
    You can call it whatever you want and I'm well aware of batching, but Epic calls it instancing in their tools:

    Because foliage instances are rendered as clusters in a single draw call..
    and that's what we're all (presumably) using and discussing. It's quite clear which one of the two that the OP was asking about, too.

    Leave a comment:


  • replied
    Sorry, I completely misread your initial post, thought you was talking abou a whole new thread on the topic.

    Leave a comment:


  • replied
    It's a couple posts above: https://forums.unrealengine.com/show...ll=1#post84119

    Leave a comment:


  • replied
    Ah, sorry, I didn't realise, I was talking about batching then and will hunt down that post.

    [EDIT] Darth, could you link to the specific post please? I'm searching the forum for recent threads on Batching and can't find any relevent to what is being discussed here.
    Last edited by Jimmy_Jazz; 06-25-2014, 05:59 PM.

    Leave a comment:


  • replied
    Instancing doesn't reduce drawcalls, if you're talking about batching, then like the post before yours then that's something different.

    Leave a comment:


  • replied
    Originally posted by darthviper107 View Post
    Instancing is all about improving memory performance, that's why things are reused as much as possible, it still has to process all of the geometry like anything else and there's a limit to how fast it can render the geometry. For something like a particle system, it may perform better because it's a single draw call, rather than many separate objects.
    It's not about memory performance, it's about the fact that issuing drawcalls is slow in (current implementations) DirectX and OpenGL.

    Leave a comment:


  • replied
    Originally posted by Mothership.Entertainment View Post
    I don't believe that's actually correct. Isn't performance kind of the whole point of instancing? I couldn't find any docs on instanced static meshes, but there's a comment in InstancedStaticMeshComponent.h that says:

    /** A component that efficiently renders multiple instances of the same StaticMesh. */

    "Efficiently" pretty clearly implies a performance improvement, not just memory savings.
    It needs bit more explanation.

    It will indeed improve performance, if you are locked on draw calls (on CPU), by batching geometry together into single call and sending it to GPU, where with "normal" meshes you have to make call for each mesh individually.
    But it will of course doesn't improve raw rendering performance. You still have to render all the geometry and do all the shading.

    It actually should be called batching, not instancing.

    Leave a comment:


  • replied
    Instancing is all about improving memory performance, that's why things are reused as much as possible, it still has to process all of the geometry like anything else and there's a limit to how fast it can render the geometry. For something like a particle system, it may perform better because it's a single draw call, rather than many separate objects.

    Leave a comment:


  • replied
    There are lots of different ways of batching things together for rendering but from what I remember in UE3, it was there for particles, but not meshes so it worked with 2D foliage, but not common meshes such as wall sections.

    Depending on how you handle things you can get groups of identical meshes to draw for the same price as just one instance of that mesh and draw calls are still one of the biggest issues for PC gaming (roll on DX12!!!).

    Leave a comment:


  • replied
    @Mothership.Entertainment, I think you're right - I think that InstancedStaticMeshes give you instanced rendering, so it basically just has the one vert/index buffer with different transforms (or whatever - don't know how it's handled precisely in UE4).

    That said, overall it's still going to be way faster for what you're doing to simply write a custom actor class that sets up your mesh dynamically (if I'm guessing right that you're interested in the instanced behavior to fix your performance issue from your other thread). This type of instancing behavior is mostly useful for cases like foliage where you have a ton of one mesh being drawn and the only thing that is really different is the transform/scale.

    It will have a lot fewer verts to send, only one transform, etc. if you do it by building a custom mesh, and if it doesn't rebuild super often the performance impact should be minimal (you could also set it up with a static index buffer I'm guessing, though that may complicate things).

    I can understand the reluctance to do that, setting up custom meshes in code tends to be a pain.
    Last edited by n00854180t; 06-25-2014, 02:54 PM.

    Leave a comment:


  • replied
    Originally posted by darthviper107 View Post
    They are instanced, but that only ever helps with memory management (in any game engine or 3D program). It means it only has to store one object in memory.
    The number of objects will greatly affect the performance, each object is a draw call.
    I don't believe that's actually correct. Isn't performance kind of the whole point of instancing? I couldn't find any docs on instanced static meshes, but there's a comment in InstancedStaticMeshComponent.h that says:

    /** A component that efficiently renders multiple instances of the same StaticMesh. */

    "Efficiently" pretty clearly implies a performance improvement, not just memory savings.
    Last edited by MSE_Taliesin; 06-25-2014, 02:18 PM.

    Leave a comment:

Working...
X