November 27th, 2020 - Jace Talk: Per-instance Custom Data

November 27th, 2020

Jace Talk: Per-instance Custom Data

https://www.youtube.com/watch?v=0kmDHBWf640&t=364

Suggested Wiki Refrence Code

Topics

    Transcription

    1. Jace

      Now this next one's really cool and I've tried to explain this and it's super hard to explain.

      So I'm going to do my best.

      I hope everyone can understand it.

      And this is her instance custom data.

      And I think this is amazing.

      First of all, the first thing you need to know is what an instance is.

      And an instance is just a copy.

      So if you build two constructors, you have two instances of a constructor, right?

      So they're just copies.

      And where the big win is here is on the rendering side of things.

      Renderers are really good at doing the same thing over and over without interruption or switching tasks.

      So what you want to do is when you have all your constructors built, for example, you want them all to be instances or you want them to be considered instances by your renderer so that it will take constructor data, what it needs to draw a constructor, and then it'll draw one

      and then it'll go, there's another one, it's the same thing, right?

      It goes all DJ Khaled on our ass, right?

      It's like, there's another one, it's a constructor, I already have that data, we'll draw it, and then just draw all the constructors, then throw that away, and then move on to the next task.

      What you don't want is for it to see two different constructors and think that they're different things, therefore treating them as different tasks, therefore requesting the same data over and over again.

      Now this can happen when, let's say, you paint them a different color with the color gun.

      The way we added the color gun into the game is we had a separate material on each unique object for every color in the color gun.

      So there are 16 colors in the color gun.

      Every single unique object, every different kind of wall, foundation,

      had 16 materials on it, one for each slot of the color gun, so that when you paint it, it will use the appropriate material that you had selected in your color gun.

      Now to you and me, we still see the constructors as instances, they're still copies, they're the same thing, they just look a little different.

      The renderer sees two constructors with different materials on, therefore different objects.

      So it won't draw them one after the other, it will separate them into tasks.

      Now that we can use per instance custom data or primitive data on each constructor, if we keep going with this example, it means we can just put one material on every constructor and have the renderer look at that data, that custom data on each instance as it draws them.

      and put it into the material and then draw.

      So basically, it means we can draw all the constructors without being interrupted and then move on to the next thing and draw all of those without being interrupted, even if you use different colors between them.

      This also adds another really big thing that isn't going to be in this upgrade, but will come in the future.

      And that is we had a 16 color color palette on the Color Gun before.

      because that was just a limitation we imposed on ourselves.

      But if we only need to use one material per object and the custom data is on the object, then that data could just be a color.

      It could be any color.

      And that means you could have infinite colors.

      So this one thing gives us a massive performance increase and it's going to allow us to expand upon the color gun.