May 28th, 2021 - Snutt & Ben Talk: Impact of the Engine Upgrade on Conveyor Belt performance

May 28th, 2021

Snutt & Ben Talk: Impact of the Engine Upgrade on Conveyor Belt performance

https://www.youtube.com/watch?v=dyqOMITwLsY&t=1330

Suggested Wiki Reference Code
Topics
  1. Ben

    make it fit for themselves

  2. Snutt

    sweet so there you go fam a little little bit of a secret thing that's coming in update five potentially hopefully fingers crossed most likely being able to do some some ux tweaks to it cool all right should we move on to the next thing

  3. Ben

    we're going to the big bus

  4. Snutt

    the big bus this one doesn't mess around the big bus

  5. Ben

    This is my beautiful test case for an unrealistic conveyor belt case.

    Let's talk about conveyor belts.

    With the engine upgrades, we faced the same issue that we got with the loading.

    The conveyor belts got way more expensive to render.

    I kind of figured out why, but we cannot change it because it's in the core of the rendering system of Unreal, which is

    such a black box to me that it's like, can't touch this.

    So we decided to find our way around it.

    Let's disable the RHI thread to begin with.

    And go to the old system of conveyor belt.

    So this is the old conveyor belt system that's still accessible to everybody.

    You can see the beautiful colors just turned yellow.

  6. Snutt

    Even on my shitty screen share, when I don't even get a proper frame rate, I'm noticing the difference here.

  7. Ben

    Yep.

    Also, a lot of items look like they're moving backwards thanks to the frame rate.

    But we figured out that updating instances became more expensive, sadly enough.

    I assume it has to do with GPU.

    bandwidth and threading and all that stuff that got improved.

    So they had to cut corners elsewhere, I assume.

    I still didn't fully figure out, but we'll see.

    So our solution to that is what if we don't update the instances?

    So

  8. Snutt

    that

  9. Ben

    was the solution in the end.

    So what we do is that we render the positions of the items on a texture and in the material we read

    where those items are.

    So if I can find that subsystem.

    Here we can see how it looks like if it doesn't crash.

    Please.

    Okay.

    So here we see all the items in the scene right

  10. Snutt

    now

  11. Ben

    on the texture.

  12. Snutt

    What a weird way to present that.

  13. Ben

    Or look at it.

    So technically it's just an array.

    a 2D array of items.

    It's a floating texture, which is not representable in colors, so that's why it looks super weird.

    Every row is an item, at least every three rows is an item, because the first ID is the lod zero, then lod one, lod, and then the last lod.

    And then we store XYZ of this, of course, and the alpha is just there.

  14. Snutt

    Interesting.

    And

  15. Ben

    we do the same for the orientation, which is looking even more weird.

    Yeah,

  16. Snutt

    I can imagine.

    Because

  17. Ben

    this is readable, but it's not because we're using quaternions.

    Yeah.

    I don't want to go into quaternions.

  18. Snutt

    Nobody wants to.

  19. Ben

    It's still weird.

    Yeah.

    They're super weird.

    It's like, let's represent an orientation with four numbers.

    Yep.

  20. Snutt

    Yeah.

  21. Ben

    Uh, and also they are going from negative one to positive one to make it even more obvious what it is.

    Uh, so yeah, we're using quaternions for that.

    The reason for that, it's easier to do it in the shader.

    You can just multiply by quaternion and then you get the right offset.

    Um, instead of doing X, Y, Z rotation, then you have to do the right order and yada yada.

  22. Snutt

    Right.

    Do you get like precision issues being that you render it to a buffer or does it actually like not really matter?

  23. Ben

    surprisingly i haven't noticed anything yet because it's in 32 bits buffer per channel

  24. Snutt

    yeah

  25. Ben

    so it's quite memory expensive but it's again it's cheaper than having an okay just just to do a few step back we used to have a instance component per unique item per conveyor belt

    Just let it sink in.

    So if you would have five different items on the long conveyor belt, you have five unique components.

    In the end, that was more of a memory sink than having a big-ass texture of 32 bits per channel.

    That was just cheaper.

    Like in the end, this is taking 1100 kilobytes to render.

    So that's pretty cheap.

  26. Snutt

    How does it scale when you have like 10 times as many conveyables as you have in this scene versus like, you know, a million, millions of conveyables or whatever.

  27. Ben

    It has a cutoff point.

    At one point, it just doesn't render the last lot.

  28. Snutt

    Right.

  29. Ben

    I'm not sure if we can get there.

    It's pretty far away.

    Yeah, here.

    You can see the purple line and the purple fade away.

    It's really difficult to see, but it's quite far.

    You can almost not see the items anymore.

    And there is consideration to make

    unlike a far distant version for far distance only but uh

  30. Snutt

    right if we

  31. Ben

    get there

  32. Snutt

    yeah

  33. Ben

    and um the biggest cost of this system is on the cpu right now uh which is costing this scene is costing 1.1 milliseconds to do to render all these items and update it because it needs to run on the game thread sadly enough

  34. Snutt

    okay

  35. Ben

    uh it was fully threaded it was fully working and then

    I pushed it out and everybody in the studio was crashing.

    I was like, but it works on my machine.

    So one of those classic ones like with threading that it works in your machine and then other people, except for only me and Dylan were running it and everybody else was crashing.

    So it was like,

  36. Snutt

    yay.

    Well, obviously you and Dylan were doing something much better than everyone else.

  37. Ben

    Of course.

  38. Snutt

    Obviously.

  39. Ben

    So yeah, I had to strip it out and have to add that back one day.

  40. Snutt

    Cool.

  41. Ben

    So yeah, those are the items.

    They all work.

  42. Snutt

    Nice.

    So I guess there's still a couple of, I've seen some people say that there's still a couple of parts that haven't moved over to the new system.

    If you do find these, make sure to go to our QA site, questions.satisfactorygame.com, and let us know.

    And that goes for all rendering issues you might face in the game.