1 00:00:04,120 --> 00:00:07,160 Speaker 1: Get in touch with technology with tech Stuff from how 2 00:00:07,200 --> 00:00:13,800 Speaker 1: stuff Works dot com. Hey there, and welcome to tech Stuff. 3 00:00:13,840 --> 00:00:16,439 Speaker 1: I'm your host, Jonathan Strickland. I'm an executive producer with 4 00:00:16,480 --> 00:00:19,919 Speaker 1: How Stuff Works and I love all things tech. It's 5 00:00:19,960 --> 00:00:23,599 Speaker 1: good to be back and listener ton Ky asked if 6 00:00:23,640 --> 00:00:27,800 Speaker 1: I could do an episode all about game engines, and 7 00:00:28,000 --> 00:00:31,480 Speaker 1: I said yes. So today we're going to learn all 8 00:00:31,520 --> 00:00:34,879 Speaker 1: about game engines. What they do? You know, what are 9 00:00:34,960 --> 00:00:37,120 Speaker 1: some of the big ones that are used in the business. 10 00:00:37,400 --> 00:00:41,680 Speaker 1: But first things first, what the heck is a game engine? Well, 11 00:00:41,760 --> 00:00:43,800 Speaker 1: a lot of this episode is going to focus on that, 12 00:00:44,200 --> 00:00:47,559 Speaker 1: But here's the too long, didn't read version if you 13 00:00:47,680 --> 00:00:50,319 Speaker 1: just want to get right down to it. It's a 14 00:00:50,400 --> 00:00:55,120 Speaker 1: framework upon which you can build a video game. But 15 00:00:55,200 --> 00:00:57,639 Speaker 1: that's doing a bit of a disservice to all the 16 00:00:57,640 --> 00:01:01,160 Speaker 1: things that a game engine allows developers to do. And 17 00:01:01,640 --> 00:01:05,880 Speaker 1: it's a complicated question to answer because there are a 18 00:01:05,920 --> 00:01:08,360 Speaker 1: lot of different game engines out there. They go about 19 00:01:08,440 --> 00:01:12,240 Speaker 1: doing what they do in different ways and to different extents. 20 00:01:12,280 --> 00:01:14,360 Speaker 1: But I'm going to do my best to kind of 21 00:01:14,360 --> 00:01:18,800 Speaker 1: take a high level view of this that is as 22 00:01:18,840 --> 00:01:23,120 Speaker 1: applicable across the board as is possible. So when you 23 00:01:23,160 --> 00:01:26,240 Speaker 1: think about a video game, everything that happens in that 24 00:01:26,319 --> 00:01:30,880 Speaker 1: game is, ultimately, when you really boil it down, a 25 00:01:30,920 --> 00:01:35,880 Speaker 1: math problem. Computers will take in input, they perform operations 26 00:01:36,080 --> 00:01:39,960 Speaker 1: on that input according to some sort of program, essentially 27 00:01:40,040 --> 00:01:44,640 Speaker 1: a set of directions or instructions, and then they produce output. 28 00:01:45,360 --> 00:01:48,280 Speaker 1: So everything that happens within the context of a computer 29 00:01:48,600 --> 00:01:53,000 Speaker 1: or video game is ultimately an expression of math as 30 00:01:53,040 --> 00:01:57,480 Speaker 1: defined by code. Now, for more than a decade, every 31 00:01:57,560 --> 00:02:00,920 Speaker 1: game that came out was essentially an ex ample of 32 00:02:01,000 --> 00:02:05,400 Speaker 1: developers building this whole thing out from scratch. They might 33 00:02:05,480 --> 00:02:08,960 Speaker 1: take some source code and make some changes in it 34 00:02:09,040 --> 00:02:11,560 Speaker 1: to create a sequel to a popular game, but most 35 00:02:11,639 --> 00:02:15,680 Speaker 1: games included new, unique code that was written in a 36 00:02:15,720 --> 00:02:18,960 Speaker 1: new way to define the virtual world and how stuff 37 00:02:19,000 --> 00:02:21,919 Speaker 1: happens within it, as well as how the program would 38 00:02:21,919 --> 00:02:25,359 Speaker 1: execute the functions that made the game playable. It would 39 00:02:25,400 --> 00:02:29,760 Speaker 1: just be written from scratch, over and over. But then 40 00:02:30,680 --> 00:02:35,520 Speaker 1: came a little game called Doom in from its software, 41 00:02:35,919 --> 00:02:39,680 Speaker 1: and its software released a press kit that's a doom 42 00:02:39,800 --> 00:02:43,600 Speaker 1: would introduce a new paradigm in gaming with the quote 43 00:02:43,680 --> 00:02:48,720 Speaker 1: unquote doom engine. John Carmack of it had come up 44 00:02:48,760 --> 00:02:52,560 Speaker 1: with a new way to define and develop games, and 45 00:02:52,560 --> 00:02:58,720 Speaker 1: it effectively split games into two general buckets of stuff. 46 00:02:59,320 --> 00:03:03,760 Speaker 1: One bigucket of stuff was all about content. The other 47 00:03:03,800 --> 00:03:07,880 Speaker 1: big bucket was the core functionality of the game itself. 48 00:03:08,240 --> 00:03:11,239 Speaker 1: So let's start with the content bucket. It's the easier 49 00:03:11,280 --> 00:03:14,240 Speaker 1: one to understand. That's where all the assets for the 50 00:03:14,280 --> 00:03:18,520 Speaker 1: game would exist. Assets could include stuff like graphics, like 51 00:03:18,600 --> 00:03:21,960 Speaker 1: all the different graphic models, what characters look like, what 52 00:03:22,120 --> 00:03:27,200 Speaker 1: settings look like. It could also include AI, behaviors or physics. 53 00:03:27,760 --> 00:03:29,720 Speaker 1: In fact, that it consists of just about all the 54 00:03:29,760 --> 00:03:32,760 Speaker 1: elements the player would experience while playing the game, So 55 00:03:32,840 --> 00:03:36,720 Speaker 1: you as the player, the stuff that you would experience, 56 00:03:36,800 --> 00:03:41,280 Speaker 1: that you would see, that you would hear. Ultimately, those 57 00:03:41,280 --> 00:03:44,240 Speaker 1: are all assets. So what the heck do I mean 58 00:03:44,280 --> 00:03:47,240 Speaker 1: by core functionality and game engines? What's left for a 59 00:03:47,280 --> 00:03:50,800 Speaker 1: game engine to do if all the content is in 60 00:03:50,840 --> 00:03:53,960 Speaker 1: this other bucket. Well, the core functionality contains all the 61 00:03:54,040 --> 00:03:56,400 Speaker 1: rules to make the stuff in the assets and the 62 00:03:56,480 --> 00:03:59,920 Speaker 1: content bucket actually work within the context of the game. 63 00:04:00,000 --> 00:04:03,480 Speaker 1: The game engine is a foundation you get. Think of 64 00:04:03,480 --> 00:04:07,560 Speaker 1: it as a scaffold or a frame, has its own 65 00:04:07,560 --> 00:04:10,440 Speaker 1: set of rules that the content has to adhere to 66 00:04:10,640 --> 00:04:13,760 Speaker 1: in order to work within the context of a game. 67 00:04:14,040 --> 00:04:18,040 Speaker 1: It is in effect a software development kit or s 68 00:04:18,160 --> 00:04:21,400 Speaker 1: d K that allows the game developers to create the 69 00:04:21,480 --> 00:04:25,600 Speaker 1: assets without having to code everything in advanced programming languages 70 00:04:25,880 --> 00:04:29,520 Speaker 1: for the most part. So Michael Inger over at Giant 71 00:04:29,560 --> 00:04:33,039 Speaker 1: Bomb created a pretty simple overview of a software and 72 00:04:33,120 --> 00:04:36,200 Speaker 1: hardware stack to kind of show where a game engine 73 00:04:36,240 --> 00:04:38,920 Speaker 1: fits in in the grand scheme of things. So, these 74 00:04:38,960 --> 00:04:43,640 Speaker 1: are different layers of operations. Uh, they're not. It's not 75 00:04:43,720 --> 00:04:48,839 Speaker 1: really physical layers, but it's a way to conceptualize this. 76 00:04:49,360 --> 00:04:52,159 Speaker 1: So at the very top layer, the layer that would 77 00:04:52,200 --> 00:04:56,520 Speaker 1: face the video game player, the part that that is 78 00:04:56,720 --> 00:04:59,640 Speaker 1: outwardly facing to the world, you have the actual game. 79 00:05:00,000 --> 00:05:02,640 Speaker 1: It's at the very top of this stack. For the 80 00:05:02,720 --> 00:05:05,440 Speaker 1: purposes of this, we're going to make up a fictional game. 81 00:05:05,480 --> 00:05:10,279 Speaker 1: I'm gonna call it tech Stuff Adventure for a princely sum. 82 00:05:10,440 --> 00:05:13,520 Speaker 1: Under that layer, you then have the game engine. So 83 00:05:13,560 --> 00:05:16,359 Speaker 1: the game sits on top of the game engine. The 84 00:05:16,440 --> 00:05:20,440 Speaker 1: game engine supports the game. Beneath the game engine, you 85 00:05:20,480 --> 00:05:23,800 Speaker 1: have what is called the application layer. This is sort 86 00:05:23,839 --> 00:05:26,640 Speaker 1: of a communication channel. It allows the game engine to 87 00:05:26,760 --> 00:05:31,760 Speaker 1: interoperate with a computer's operating system. That's the next layer down. 88 00:05:31,839 --> 00:05:35,839 Speaker 1: So we're familiar with operating systems things like Windows, uh, 89 00:05:36,080 --> 00:05:41,520 Speaker 1: mac os. Those are the user interfaces to interact with 90 00:05:41,560 --> 00:05:46,680 Speaker 1: a computer. More directly below the operating system level is 91 00:05:46,920 --> 00:05:51,600 Speaker 1: BIOS that's basic input output layer. This is sort of 92 00:05:51,640 --> 00:05:56,800 Speaker 1: the firmware that allows the actual communication between the software 93 00:05:56,880 --> 00:06:01,560 Speaker 1: and the hardware. Beneath BIO is the actual hardware, the 94 00:06:01,600 --> 00:06:06,320 Speaker 1: actual circuitry that the computer runs on. Beneath that is 95 00:06:06,360 --> 00:06:10,200 Speaker 1: the electricity that is powering everything. That is the different 96 00:06:10,400 --> 00:06:15,000 Speaker 1: different cotrols and voltage that indicate whether it's a zero 97 00:06:15,160 --> 00:06:18,880 Speaker 1: or a one essentially, and as Anger points out, game 98 00:06:18,920 --> 00:06:22,599 Speaker 1: engines will sometimes communicate straight through to the BIOS layer. 99 00:06:22,880 --> 00:06:26,520 Speaker 1: They skip the application and operating system layer and will 100 00:06:26,560 --> 00:06:29,560 Speaker 1: interact directly with a bioslayer, And this helps maximize the 101 00:06:29,600 --> 00:06:32,920 Speaker 1: efficiency of hardware usage. It means the game can take 102 00:06:33,000 --> 00:06:36,320 Speaker 1: up more of the computer's assets and create a more 103 00:06:36,560 --> 00:06:41,279 Speaker 1: immersive experience. Now, around the time that Doom launched, computer 104 00:06:41,360 --> 00:06:45,440 Speaker 1: games were becoming pretty sophisticated. They were pushing hardware to 105 00:06:45,520 --> 00:06:49,279 Speaker 1: the limits, and building a game from scratch was becoming 106 00:06:49,279 --> 00:06:52,280 Speaker 1: a more daunting prospect. You know, way back in the day, 107 00:06:52,800 --> 00:06:56,719 Speaker 1: a single person could create a triple A title game 108 00:06:57,120 --> 00:07:01,160 Speaker 1: out of a garage using a simple computer. But by 109 00:07:01,200 --> 00:07:03,320 Speaker 1: the time Doom was coming around, these games were becoming 110 00:07:03,360 --> 00:07:07,279 Speaker 1: so sophisticated, so complicated that it required a team of 111 00:07:07,320 --> 00:07:10,280 Speaker 1: developers working together to get it done in any reasonable 112 00:07:10,280 --> 00:07:13,840 Speaker 1: amount of time, and developing a single game was taking 113 00:07:13,960 --> 00:07:16,560 Speaker 1: longer and a lot more people than games from just 114 00:07:16,640 --> 00:07:19,640 Speaker 1: a few years earlier. So game engines helped reduce the 115 00:07:19,680 --> 00:07:22,960 Speaker 1: amount of time and efforts spent developing a game. For 116 00:07:23,040 --> 00:07:26,720 Speaker 1: as long as the game engine remains relevant. Game engines 117 00:07:26,800 --> 00:07:31,320 Speaker 1: can age into you know, obsolescence. You can get a 118 00:07:31,360 --> 00:07:34,760 Speaker 1: game engine that no longer can take advantage of hardware 119 00:07:34,760 --> 00:07:38,240 Speaker 1: to a point that makes it meaningful. But a lot 120 00:07:38,280 --> 00:07:42,480 Speaker 1: of game engines are upgradeable, so we'll get into that 121 00:07:42,480 --> 00:07:45,560 Speaker 1: a little bit more later now, to make matters more complicated. 122 00:07:45,840 --> 00:07:48,880 Speaker 1: Around the same time when Doom was coming out, we 123 00:07:48,920 --> 00:07:53,000 Speaker 1: started to see an incredible growth and expansion cards for computers, 124 00:07:53,040 --> 00:07:56,320 Speaker 1: both for graphics cards and audio cards. If you listen 125 00:07:56,400 --> 00:07:59,600 Speaker 1: to my in vidio episodes, you'll likely remember this was 126 00:07:59,640 --> 00:08:03,680 Speaker 1: a time aime of competing standards in hardware and application 127 00:08:03,720 --> 00:08:07,720 Speaker 1: programmer interfaces and developing a game for the PC started 128 00:08:07,760 --> 00:08:11,800 Speaker 1: to get tough because these standards in hardware were changing 129 00:08:11,840 --> 00:08:15,040 Speaker 1: so rapidly. You wanted your game to be as pretty 130 00:08:15,280 --> 00:08:17,960 Speaker 1: and as as advanced as it possibly could be. You 131 00:08:18,000 --> 00:08:22,080 Speaker 1: wanted to be at that leading edge, but the development 132 00:08:22,160 --> 00:08:25,200 Speaker 1: cycle for a game might not match up with the 133 00:08:25,240 --> 00:08:28,320 Speaker 1: advancement of hardware. You know, you might be working on 134 00:08:28,360 --> 00:08:32,200 Speaker 1: a game on one standard of hardware, and while you're 135 00:08:32,200 --> 00:08:35,880 Speaker 1: working on the game, the hardware is you know, upgraded, 136 00:08:36,240 --> 00:08:39,680 Speaker 1: and you're still working on the older version. So it 137 00:08:39,800 --> 00:08:44,959 Speaker 1: was really challenging. The big difference here for PCs versus 138 00:08:45,000 --> 00:08:46,840 Speaker 1: consoles is that you didn't have to worry about this 139 00:08:46,880 --> 00:08:51,640 Speaker 1: with consoles. Consoles are different. A console's hardware remains consistent. 140 00:08:51,920 --> 00:08:55,800 Speaker 1: Typically you might get a new version of that console 141 00:08:55,880 --> 00:09:00,280 Speaker 1: that has beefier specs, but consoles tend to be locked down. 142 00:09:00,640 --> 00:09:04,120 Speaker 1: You don't expand them with new hardware, so there's not 143 00:09:04,240 --> 00:09:07,240 Speaker 1: really any worry about that. You can develop a game 144 00:09:07,320 --> 00:09:12,520 Speaker 1: for that specific hardware specification and be reasonably sure that's 145 00:09:12,559 --> 00:09:17,400 Speaker 1: going to apply across the entire spectrum, so you don't 146 00:09:17,400 --> 00:09:21,440 Speaker 1: have to worry about this fast development cycle of expansion cards. 147 00:09:21,880 --> 00:09:24,400 Speaker 1: Now there are many different types of game engines, and 148 00:09:24,480 --> 00:09:27,360 Speaker 1: thus there are different approaches to building out a framework. 149 00:09:27,600 --> 00:09:31,640 Speaker 1: It's kind of like programming languages. A programming language is 150 00:09:31,679 --> 00:09:34,600 Speaker 1: purpose is to give a person, you know, the programmer, 151 00:09:35,000 --> 00:09:37,960 Speaker 1: the ability to create a set of instructions for a 152 00:09:38,000 --> 00:09:42,560 Speaker 1: computer to follow. But computers understand machine code, and that 153 00:09:42,800 --> 00:09:45,000 Speaker 1: tends to me very hard for humans to work with. 154 00:09:45,160 --> 00:09:49,160 Speaker 1: It's not intuitive, it's easy to lose your place. Humans 155 00:09:49,200 --> 00:09:52,840 Speaker 1: do much better with more abstract languages that can be 156 00:09:52,880 --> 00:09:57,559 Speaker 1: converted into machine code for computers to follow those instructions. 157 00:09:57,800 --> 00:10:00,280 Speaker 1: So the language the humans use and lang which the 158 00:10:00,320 --> 00:10:05,080 Speaker 1: computers use are different. They require an interpreter between them. 159 00:10:05,280 --> 00:10:08,720 Speaker 1: Game engines are kind of like the same thing, except 160 00:10:08,760 --> 00:10:11,960 Speaker 1: they go one step further out from programming languages to 161 00:10:12,000 --> 00:10:15,240 Speaker 1: create a platform upon which game developers can build out 162 00:10:15,280 --> 00:10:19,800 Speaker 1: their games. Harold Serrano wrote a great overview of game 163 00:10:19,840 --> 00:10:24,040 Speaker 1: engines and breaks them down into three smaller entities. At 164 00:10:24,080 --> 00:10:26,360 Speaker 1: the top is why he calls a math engine that 165 00:10:26,480 --> 00:10:29,000 Speaker 1: handles all the operations that the rest of the game 166 00:10:29,040 --> 00:10:32,480 Speaker 1: relies upon, and that sends those instructions to the computer. 167 00:10:32,800 --> 00:10:35,640 Speaker 1: It's the heart of the game engine. It contains the 168 00:10:35,760 --> 00:10:39,160 Speaker 1: rules for all those operations, whether they be vector operations 169 00:10:39,200 --> 00:10:44,599 Speaker 1: such as addition and subtraction, or matrix operations like transforms 170 00:10:44,640 --> 00:10:48,400 Speaker 1: or transpositions. Then Serrano writes, you have the two engines 171 00:10:48,440 --> 00:10:51,360 Speaker 1: that this math engine feeds into, and those would be 172 00:10:51,360 --> 00:10:54,800 Speaker 1: the rendering engine and the physics engine. And we'll start 173 00:10:54,800 --> 00:10:58,600 Speaker 1: by talking about the renderer or rendering engine. And for 174 00:10:58,679 --> 00:11:01,280 Speaker 1: a lot of this I'm relying up Bond The Incredible 175 00:11:02,200 --> 00:11:06,800 Speaker 1: an exhaustive series of articles on Extreme Tech about the 176 00:11:06,800 --> 00:11:10,640 Speaker 1: anatomy of a game engine. It's an eleven part series. 177 00:11:10,679 --> 00:11:13,440 Speaker 1: They were written by a game designer named Jake Simpson. 178 00:11:14,080 --> 00:11:16,880 Speaker 1: Uh the articles came out in two thousand two, so 179 00:11:17,000 --> 00:11:20,720 Speaker 1: they're a little dated, but the general principles remain sound. 180 00:11:21,120 --> 00:11:23,200 Speaker 1: So if at the end of this episode you still 181 00:11:23,240 --> 00:11:25,880 Speaker 1: want to learn a lot more about game engines, and 182 00:11:25,960 --> 00:11:29,600 Speaker 1: I mean a lot more, go check out that series 183 00:11:29,600 --> 00:11:32,480 Speaker 1: of articles over at Extreme Tech, because Jake Simpson wrote 184 00:11:32,520 --> 00:11:37,920 Speaker 1: about twenty six thousand words on the subject. It's an 185 00:11:37,920 --> 00:11:42,040 Speaker 1: incredible account. Anyway, the renderer's job is to produce the 186 00:11:42,120 --> 00:11:45,720 Speaker 1: visualizations of data so that there's something for the player 187 00:11:45,760 --> 00:11:49,120 Speaker 1: to look at. It is creating the visuals on the screen. 188 00:11:49,200 --> 00:11:52,280 Speaker 1: According to the current state of the game, and it 189 00:11:52,320 --> 00:11:55,800 Speaker 1: does this rapidly, multiple times a second, and in reaction 190 00:11:55,880 --> 00:11:59,160 Speaker 1: to the inputs it receives. So in the first person shooter, 191 00:11:59,440 --> 00:12:02,320 Speaker 1: that can include changing the angle of view as a 192 00:12:02,320 --> 00:12:04,640 Speaker 1: player turns the character to the left or to the right, 193 00:12:05,000 --> 00:12:08,120 Speaker 1: as well as the way that graphics are changing as 194 00:12:08,240 --> 00:12:12,079 Speaker 1: enemies are moving closer or further away, or they're moving 195 00:12:12,120 --> 00:12:16,520 Speaker 1: behind cover. All of these things affect what the renderer 196 00:12:16,559 --> 00:12:20,120 Speaker 1: has to create for us to see. Now, you don't 197 00:12:20,160 --> 00:12:24,080 Speaker 1: actually build those elements in the renderer. You would use 198 00:12:24,120 --> 00:12:28,520 Speaker 1: a different tool to build all of these graphic models themselves. 199 00:12:28,920 --> 00:12:32,040 Speaker 1: You might use something like Maya or Blender, and that's 200 00:12:32,040 --> 00:12:36,080 Speaker 1: where you would design all of these graphic elements. The 201 00:12:36,160 --> 00:12:40,120 Speaker 1: game engines renderer is in charge of taking those assets 202 00:12:40,440 --> 00:12:44,120 Speaker 1: and displaying them in the appropriate way on the screen 203 00:12:44,640 --> 00:12:48,200 Speaker 1: so that they are in the right location, at the 204 00:12:48,320 --> 00:12:51,840 Speaker 1: right size, at the right orientation, with the right lighting effects, 205 00:12:51,840 --> 00:12:55,000 Speaker 1: the right texture effects. All of those things have to 206 00:12:55,040 --> 00:12:59,080 Speaker 1: be just right based upon the moment you are seeing 207 00:12:59,120 --> 00:13:03,839 Speaker 1: them in the game, and the game engine handles those rules. Now, 208 00:13:03,840 --> 00:13:07,400 Speaker 1: there's more important stuff about things like light effects and 209 00:13:07,520 --> 00:13:10,040 Speaker 1: textures that I need to get into. But first let's 210 00:13:10,080 --> 00:13:20,960 Speaker 1: take a quick break and thank our sponsor. Now, the 211 00:13:21,040 --> 00:13:26,080 Speaker 1: rendering engine creates a really big demand on computer processors 212 00:13:26,080 --> 00:13:29,040 Speaker 1: in general. Back in the day we're talking, it could 213 00:13:29,040 --> 00:13:33,280 Speaker 1: represent or more of all the CPUs processing time on 214 00:13:33,360 --> 00:13:37,319 Speaker 1: a game. And with the invention of graphics processing units 215 00:13:37,440 --> 00:13:41,760 Speaker 1: or GPUs as we've called them, building a renderer requires 216 00:13:41,800 --> 00:13:47,959 Speaker 1: an extensive understanding of hardware and three dimensional math. Virtual 217 00:13:48,040 --> 00:13:51,920 Speaker 1: three dimensional objects exists as a series of points in 218 00:13:52,040 --> 00:13:54,240 Speaker 1: virtual space, so you can kind of think of as 219 00:13:54,240 --> 00:13:58,000 Speaker 1: connect the dots, except it's connect the dots in three dimensions, 220 00:13:58,000 --> 00:14:02,160 Speaker 1: not just in two, and the dot are points called vertices. 221 00:14:02,600 --> 00:14:07,920 Speaker 1: Programmers create models that define the relationship between vertices so 222 00:14:07,960 --> 00:14:11,400 Speaker 1: that the computer knows how far apart any two given 223 00:14:11,520 --> 00:14:15,679 Speaker 1: vertices are from each other. So, for example, let's say 224 00:14:15,679 --> 00:14:19,800 Speaker 1: you're building a pyramid, just a static pyramid in virtual space. 225 00:14:20,560 --> 00:14:24,520 Speaker 1: A pyramid has four sides, and the computer would have 226 00:14:24,600 --> 00:14:27,880 Speaker 1: to understand how far apart the different points of the 227 00:14:27,920 --> 00:14:30,400 Speaker 1: pyramid are from each other. From the tippy top of 228 00:14:30,440 --> 00:14:33,320 Speaker 1: the pyramid to the four points along the base of 229 00:14:33,360 --> 00:14:36,400 Speaker 1: the pyramid, they would all have a certain distance from 230 00:14:36,440 --> 00:14:39,680 Speaker 1: one another that would remain the same no matter what 231 00:14:39,760 --> 00:14:44,800 Speaker 1: orientation you put that pyramid in because the pyramid is 232 00:14:44,840 --> 00:14:50,160 Speaker 1: a static object. It's not flippy filippy. So uh, the 233 00:14:50,160 --> 00:14:54,040 Speaker 1: game engine understands that that virtual object has four faces, 234 00:14:54,840 --> 00:14:57,520 Speaker 1: three that face outward and one that would face downward, 235 00:14:58,040 --> 00:15:01,080 Speaker 1: and complex shapes and video games are made up of 236 00:15:01,120 --> 00:15:03,800 Speaker 1: things like this, like surfaces like this, except they're made 237 00:15:03,840 --> 00:15:08,000 Speaker 1: up of thousands or hundreds of thousands of polygons. Now 238 00:15:08,040 --> 00:15:11,480 Speaker 1: you can imagine that the game sends instructions to the 239 00:15:11,520 --> 00:15:15,640 Speaker 1: renderer to display the appropriate graphics at the appropriate angles, 240 00:15:15,880 --> 00:15:19,720 Speaker 1: with the appropriate orientations, with regard to each other. The 241 00:15:19,760 --> 00:15:22,760 Speaker 1: game doesn't have to understand how the renderer does this. 242 00:15:23,120 --> 00:15:25,760 Speaker 1: It's just saying something like, I need you to show 243 00:15:26,160 --> 00:15:30,880 Speaker 1: this tree over here, a mountain over there, and I 244 00:15:30,920 --> 00:15:34,960 Speaker 1: don't know a rabbit, wear rabbit over in this direction, 245 00:15:35,200 --> 00:15:38,040 Speaker 1: and the renderer follows the set of rules to display 246 00:15:38,240 --> 00:15:41,520 Speaker 1: those things so that they appear correctly within the context 247 00:15:41,600 --> 00:15:43,920 Speaker 1: of a player's point of view, so that the rabbit 248 00:15:43,960 --> 00:15:47,680 Speaker 1: doesn't appear to be larger than the mountain, for example. Now, 249 00:15:47,720 --> 00:15:50,360 Speaker 1: one thing a rendering engine can do to manage this 250 00:15:50,520 --> 00:15:53,840 Speaker 1: massive amount of data that it has to handle is 251 00:15:53,920 --> 00:15:59,360 Speaker 1: a process that's called culling. Culling involves eliminating the need 252 00:15:59,400 --> 00:16:03,200 Speaker 1: to calculate the math that represents stuff you cannot see 253 00:16:03,640 --> 00:16:07,960 Speaker 1: from your perspective. So here's some examples. If there are 254 00:16:07,960 --> 00:16:11,200 Speaker 1: objects that are very very far away from you, so 255 00:16:11,240 --> 00:16:15,160 Speaker 1: they are beyond where your vision could detect them, that's 256 00:16:15,160 --> 00:16:18,120 Speaker 1: not going to be represented, so that math can be dropped. 257 00:16:18,200 --> 00:16:20,720 Speaker 1: There's no need to worry about it because you can't 258 00:16:20,760 --> 00:16:24,040 Speaker 1: see it anyway. A lot of games will introduce fog 259 00:16:24,320 --> 00:16:27,200 Speaker 1: for this purpose, and you'll have fog that cuts off 260 00:16:27,240 --> 00:16:30,080 Speaker 1: your vision at a certain distance, and that way the 261 00:16:30,160 --> 00:16:34,120 Speaker 1: rendering engine doesn't have to draw progressively smaller and smaller 262 00:16:34,240 --> 00:16:41,040 Speaker 1: landmarks off into the distance. Then there's also things like occlusion. 263 00:16:41,760 --> 00:16:45,440 Speaker 1: This is when you have one object blocking some or 264 00:16:45,520 --> 00:16:48,720 Speaker 1: all of another object. So, for example, let's say you're 265 00:16:48,720 --> 00:16:52,000 Speaker 1: playing a fantasy game. You're playing an Elder Scrolls game. 266 00:16:52,120 --> 00:16:55,520 Speaker 1: Let's say, and you're looking at a forest uh in 267 00:16:55,600 --> 00:16:57,920 Speaker 1: a mountain range, and you see a frost troll and 268 00:16:57,960 --> 00:17:00,480 Speaker 1: the frost trols lurking behind the rocks. You can only 269 00:17:00,480 --> 00:17:02,960 Speaker 1: see part of the frost trol. Well, some of that 270 00:17:03,000 --> 00:17:06,920 Speaker 1: frost trol obviously is obscured by the scenery. So rather 271 00:17:06,960 --> 00:17:10,760 Speaker 1: than calculate all the information that represents that frost trol 272 00:17:10,960 --> 00:17:14,240 Speaker 1: in its entirety, the culling process would remove any of 273 00:17:14,240 --> 00:17:16,080 Speaker 1: the bits that would be out of your view due 274 00:17:16,080 --> 00:17:18,000 Speaker 1: to the rock. It would say, oh, we don't need 275 00:17:18,040 --> 00:17:20,840 Speaker 1: to calculate this stuff because the player can't see it, 276 00:17:20,960 --> 00:17:23,240 Speaker 1: so we're just gonna leave that out. We'll just include 277 00:17:23,240 --> 00:17:25,720 Speaker 1: the stuff that the player can see based upon their 278 00:17:25,800 --> 00:17:29,800 Speaker 1: angle of view. The rendering engine is only concerned with 279 00:17:29,880 --> 00:17:32,280 Speaker 1: the bits you can actually see, which is in a 280 00:17:32,359 --> 00:17:36,280 Speaker 1: way kind of like lossy audio compression formats like MP 281 00:17:36,440 --> 00:17:38,840 Speaker 1: three you remember, I've talked about that in the past, 282 00:17:38,880 --> 00:17:41,560 Speaker 1: where MP three files. One of the reasons they are 283 00:17:41,600 --> 00:17:45,160 Speaker 1: so much smaller than raw audio files is that they 284 00:17:45,200 --> 00:17:48,960 Speaker 1: eliminate all the sounds that are, at least in theory, 285 00:17:49,000 --> 00:17:53,159 Speaker 1: outside the range of human hearing. Because if it's outside 286 00:17:53,160 --> 00:17:55,840 Speaker 1: the range of human hearing, if we cannot perceive it, 287 00:17:55,920 --> 00:17:59,840 Speaker 1: there's no need to preserve that information, at least in theory. 288 00:18:00,320 --> 00:18:04,000 Speaker 1: Rendering also sets the rules for how graphics will pop 289 00:18:04,040 --> 00:18:08,000 Speaker 1: into view. So, for example, translucent surfaces things that you 290 00:18:08,040 --> 00:18:12,080 Speaker 1: can see through have to render in after the opaque surfaces, 291 00:18:12,600 --> 00:18:15,680 Speaker 1: and that way you can see through the translucent ones properly. 292 00:18:16,000 --> 00:18:19,000 Speaker 1: So let's say you're looking through Let's say it's a waterfall. 293 00:18:19,280 --> 00:18:21,600 Speaker 1: It's a very thin waterfall, and you can see through 294 00:18:21,640 --> 00:18:25,120 Speaker 1: it to the other side. Well, the other side would 295 00:18:25,119 --> 00:18:28,040 Speaker 1: have to render in first, and then the waterfall would 296 00:18:28,040 --> 00:18:30,640 Speaker 1: render in. Uh. And so you can think of it 297 00:18:30,800 --> 00:18:34,040 Speaker 1: as a sequence that goes back to front, the further 298 00:18:34,160 --> 00:18:39,520 Speaker 1: away from you, the back surfaces that should come in first, 299 00:18:39,600 --> 00:18:41,680 Speaker 1: and then the surfaces ahead of time. So maybe there's 300 00:18:41,720 --> 00:18:46,440 Speaker 1: a lighting uh see, a lighting source that's between the 301 00:18:46,480 --> 00:18:50,480 Speaker 1: waterfall and whatever is behind it that would look come 302 00:18:50,520 --> 00:18:52,720 Speaker 1: in next, and then the waterfall would come in last. 303 00:18:52,880 --> 00:18:55,000 Speaker 1: But this all happens, or at least it should happen 304 00:18:55,359 --> 00:18:59,720 Speaker 1: very very very quickly. So preferably it's fast enough where 305 00:18:59,720 --> 00:19:01,920 Speaker 1: you even be noticeable. It would all just seem to 306 00:19:01,960 --> 00:19:04,640 Speaker 1: appear at the same time. That's not always the case. 307 00:19:04,680 --> 00:19:07,400 Speaker 1: If you're playing a very advanced game on high settings, 308 00:19:07,440 --> 00:19:10,720 Speaker 1: on hardware that can't quite handle it, you'll run into 309 00:19:10,800 --> 00:19:13,119 Speaker 1: problems when this stuff starts to try and kick in. 310 00:19:13,720 --> 00:19:17,040 Speaker 1: The rendering engine also has to take other factors into account. 311 00:19:17,080 --> 00:19:20,320 Speaker 1: The game will send information about textures, and the renderer 312 00:19:20,359 --> 00:19:23,840 Speaker 1: has to apply those textures to the various polygons in 313 00:19:23,880 --> 00:19:27,560 Speaker 1: the view. So otherwise, if you didn't have textures, you 314 00:19:27,600 --> 00:19:30,240 Speaker 1: would just end up with a messy wire frame universe. 315 00:19:30,280 --> 00:19:32,680 Speaker 1: It would be very hard to be able to make 316 00:19:32,680 --> 00:19:35,679 Speaker 1: heads or tails out of anything, especially for very complicated 317 00:19:36,280 --> 00:19:39,080 Speaker 1: graphics heavy games. It would just be these sets of 318 00:19:39,160 --> 00:19:42,040 Speaker 1: lines and polygons and you wouldn't be able to tell 319 00:19:42,040 --> 00:19:47,480 Speaker 1: what is what. After the renderer UH has to calculate 320 00:19:47,680 --> 00:19:50,359 Speaker 1: the textures, it then has to figure out how bright 321 00:19:50,480 --> 00:19:53,760 Speaker 1: each surface should be given the light sources in the area. 322 00:19:53,760 --> 00:19:57,680 Speaker 1: It has to apply logic to the lighting. So if 323 00:19:57,720 --> 00:20:00,639 Speaker 1: you have a torch on a wall and you have 324 00:20:00,680 --> 00:20:04,359 Speaker 1: an object that would be partly illuminated by this torch, 325 00:20:05,160 --> 00:20:07,240 Speaker 1: some parts of the surface of that object should be 326 00:20:07,240 --> 00:20:09,879 Speaker 1: brighter than others, and the game engine is responsible for 327 00:20:09,960 --> 00:20:13,280 Speaker 1: applying this logic in a way that makes sense based 328 00:20:13,359 --> 00:20:16,720 Speaker 1: upon where the light sources are in your area. So 329 00:20:17,040 --> 00:20:20,879 Speaker 1: if you're in a dark corridor aboard a defunct space station, 330 00:20:20,920 --> 00:20:24,080 Speaker 1: the sparse light sources will highlight some surfaces will leave 331 00:20:24,160 --> 00:20:26,800 Speaker 1: others in shadow, and the renderer has to take into 332 00:20:26,840 --> 00:20:30,000 Speaker 1: account all of this when drawing out the scene. It 333 00:20:30,080 --> 00:20:33,240 Speaker 1: also has to do some collision detection as well, although 334 00:20:33,280 --> 00:20:36,879 Speaker 1: that will come into play also with physics and AI. 335 00:20:37,040 --> 00:20:40,560 Speaker 1: But collision detection is when you have two virtual elements 336 00:20:40,600 --> 00:20:43,399 Speaker 1: that would come into contact with one another within the 337 00:20:43,480 --> 00:20:46,680 Speaker 1: virtual environment. So in the real world, if you had 338 00:20:46,720 --> 00:20:50,520 Speaker 1: real things, they would hit each other. Well, these are 339 00:20:50,600 --> 00:20:54,080 Speaker 1: virtual objects. They don't they don't have any actual mass. 340 00:20:54,680 --> 00:20:58,720 Speaker 1: But with good collision detection, virtual elements will appear to 341 00:20:58,800 --> 00:21:02,720 Speaker 1: move naturally with hard to each other, and they'll appear 342 00:21:02,840 --> 00:21:06,720 Speaker 1: to have this contact and the reaction to that contact, 343 00:21:06,760 --> 00:21:09,280 Speaker 1: and they won't just pass through. Otherwise it would be 344 00:21:09,840 --> 00:21:13,280 Speaker 1: like you're phasing through solid objects, and that kind of 345 00:21:13,320 --> 00:21:16,280 Speaker 1: breaks the immersion of a video game if that was 346 00:21:16,320 --> 00:21:20,040 Speaker 1: not intended. If you want to learn way more about lighting, 347 00:21:20,080 --> 00:21:22,520 Speaker 1: I recommend reading the Anatomy of a Game Engine articles 348 00:21:22,560 --> 00:21:25,760 Speaker 1: I mentioned already by Jake Simpson, because he goes into 349 00:21:25,800 --> 00:21:28,840 Speaker 1: a lot more detail over the various approaches to lighting. 350 00:21:28,880 --> 00:21:33,320 Speaker 1: I'm grouping them all in a general category, but there 351 00:21:33,359 --> 00:21:39,440 Speaker 1: are several different methods to going about lighting scenes in games, 352 00:21:39,520 --> 00:21:43,159 Speaker 1: and Simpson goes through them and and much more detail 353 00:21:43,200 --> 00:21:44,800 Speaker 1: than I will hear. I don't want to do a 354 00:21:45,200 --> 00:21:48,639 Speaker 1: fifteen episode series about game engines. It is fascinating, but 355 00:21:48,680 --> 00:21:50,359 Speaker 1: it goes further in the weeds than I think we 356 00:21:50,440 --> 00:21:52,919 Speaker 1: need to for this episode. Will just allow that the 357 00:21:52,960 --> 00:21:55,880 Speaker 1: rendering engine has to take all these different factors into 358 00:21:55,880 --> 00:21:59,000 Speaker 1: account to display the assets of the game properly for 359 00:21:59,040 --> 00:22:03,080 Speaker 1: the player. Now, one really interesting thing about rendering engines 360 00:22:03,320 --> 00:22:06,320 Speaker 1: is that if you design it properly, you can make 361 00:22:06,359 --> 00:22:10,800 Speaker 1: it really modular within the larger game engine itself. Remember, 362 00:22:10,840 --> 00:22:14,399 Speaker 1: the rendering engine is just one component of the game engine. 363 00:22:15,240 --> 00:22:18,879 Speaker 1: Now that means you could overhaul the rendering engine for 364 00:22:19,000 --> 00:22:24,960 Speaker 1: future games, you get more advanced ways of creating, uh 365 00:22:25,000 --> 00:22:29,360 Speaker 1: the graphics. Maybe there are new effects that you can apply. Well, 366 00:22:29,400 --> 00:22:33,520 Speaker 1: you can actually create a new rendering engine and disconnect 367 00:22:33,560 --> 00:22:36,160 Speaker 1: the old one from your game engine, plug the new 368 00:22:36,160 --> 00:22:38,760 Speaker 1: one in, and it should work with all the other 369 00:22:38,800 --> 00:22:43,080 Speaker 1: components seamlessly. If you actually built your game engine in 370 00:22:43,119 --> 00:22:46,880 Speaker 1: that way, you have to actually have built it this way, 371 00:22:46,920 --> 00:22:49,760 Speaker 1: but it's possible. You can make this where the rendering 372 00:22:49,760 --> 00:22:52,600 Speaker 1: engine is sort of a plug in play approach. It's 373 00:22:52,600 --> 00:22:55,119 Speaker 1: a little more complicated than that, but that's the concept. 374 00:22:55,920 --> 00:22:58,720 Speaker 1: It's way easier said than done, but it's one of 375 00:22:58,760 --> 00:23:01,680 Speaker 1: the ways legacy game jids have stuck around for so long. 376 00:23:02,200 --> 00:23:05,359 Speaker 1: It's not that people perfected the game engine a decade ago. 377 00:23:05,800 --> 00:23:09,000 Speaker 1: It's that the game engines elements can evolve over time 378 00:23:09,320 --> 00:23:12,640 Speaker 1: and plug back into the overall engine itself to give 379 00:23:12,640 --> 00:23:15,600 Speaker 1: it more usefulness. Now there's a lot more to talk 380 00:23:15,640 --> 00:23:18,480 Speaker 1: about when it comes to rendering images, and some of 381 00:23:18,480 --> 00:23:20,440 Speaker 1: the stuff I'm going to mention in the next section 382 00:23:20,480 --> 00:23:23,960 Speaker 1: will come back to touch on rendering. But rendering as 383 00:23:23,960 --> 00:23:26,600 Speaker 1: fascinating as it is and as advanced as it gets 384 00:23:26,600 --> 00:23:29,280 Speaker 1: with all the different particle effects and lighting effects and 385 00:23:29,320 --> 00:23:32,199 Speaker 1: texture mapping and all that is only part of the 386 00:23:32,200 --> 00:23:34,359 Speaker 1: game engine. We still have a lot more to talk about, 387 00:23:34,640 --> 00:23:37,280 Speaker 1: which I'll get to right after we take this break 388 00:23:37,520 --> 00:23:47,960 Speaker 1: to thank our sponsor. The game engine can also play 389 00:23:48,000 --> 00:23:52,720 Speaker 1: a really important role in sending audio information to computer hardware. Now, again, 390 00:23:53,000 --> 00:23:56,720 Speaker 1: the audio itself, that's those are assets, But the game 391 00:23:56,760 --> 00:24:00,960 Speaker 1: engine determines how the audio plays out within the context 392 00:24:01,000 --> 00:24:04,119 Speaker 1: of the game, and it might send information out to 393 00:24:04,160 --> 00:24:07,479 Speaker 1: a dedicated sound card, or these days it might be 394 00:24:07,520 --> 00:24:12,040 Speaker 1: through an integrated audio that's already on the motherboard and 395 00:24:12,080 --> 00:24:15,920 Speaker 1: then directly onto speakers or headphones. Back when I got 396 00:24:15,960 --> 00:24:19,119 Speaker 1: fed up with PC gaming in the nineties, and that 397 00:24:19,200 --> 00:24:22,159 Speaker 1: was because there were these different graphics and sound cards. 398 00:24:22,160 --> 00:24:27,280 Speaker 1: They're all battling for supremacy, and getting one set of 399 00:24:28,080 --> 00:24:31,119 Speaker 1: sound cards or graphics cards could mean missing out on 400 00:24:31,240 --> 00:24:34,520 Speaker 1: some games that don't support those formats, or getting a 401 00:24:34,600 --> 00:24:37,600 Speaker 1: less enjoyable experience because you have to emulate something else. 402 00:24:37,920 --> 00:24:39,760 Speaker 1: And now I'll have to do a whole episode on 403 00:24:39,800 --> 00:24:42,479 Speaker 1: the history of sound cards at some point, because it's 404 00:24:42,520 --> 00:24:46,879 Speaker 1: also really interesting history. But the important thing to remember 405 00:24:46,920 --> 00:24:51,560 Speaker 1: now is that since or So Intel, what they came 406 00:24:51,560 --> 00:24:55,360 Speaker 1: out with the a C audio CODAC back that made 407 00:24:55,400 --> 00:24:59,400 Speaker 1: it possible for hardware manufacturers to include an integrated chip 408 00:25:00,040 --> 00:25:03,280 Speaker 1: on the motherboard that could emulate a sound Blaster sixteen 409 00:25:03,359 --> 00:25:07,920 Speaker 1: audio card. And since then we've seen advances in integrated audio, 410 00:25:08,400 --> 00:25:12,879 Speaker 1: which has reduced the necessity to have an additional sound 411 00:25:12,880 --> 00:25:16,640 Speaker 1: card installed on your computer. Back in the day, if 412 00:25:16,640 --> 00:25:18,800 Speaker 1: you wanted to have really good sound, you had to 413 00:25:18,800 --> 00:25:22,720 Speaker 1: buy a sound card because the IBM and IBM compatible 414 00:25:22,760 --> 00:25:26,679 Speaker 1: computers only had a speaker that could create just simple tones, 415 00:25:26,920 --> 00:25:29,520 Speaker 1: one tone at a time, and there was no variation 416 00:25:29,560 --> 00:25:32,680 Speaker 1: in volume. So if you wanted any more complexity or sophistication, 417 00:25:32,720 --> 00:25:35,919 Speaker 1: you had to get a standalone sound card. That's not 418 00:25:35,960 --> 00:25:39,320 Speaker 1: the case today now we have these integrated audio features. 419 00:25:39,359 --> 00:25:42,200 Speaker 1: Some gamers argue that you still want to have a 420 00:25:42,280 --> 00:25:46,520 Speaker 1: standalone sound card to really get the fidelity necessary for 421 00:25:46,720 --> 00:25:50,239 Speaker 1: a really good gaming experience. Also, they tend to be 422 00:25:50,240 --> 00:25:54,320 Speaker 1: better if you want to use voice while you're playing 423 00:25:55,000 --> 00:25:57,879 Speaker 1: UM and you want your voice to sound good. Sometimes 424 00:25:57,960 --> 00:26:01,400 Speaker 1: that means getting your own independent sound card with your computer, 425 00:26:01,480 --> 00:26:04,520 Speaker 1: But more and more gamers these days seem to rely 426 00:26:04,880 --> 00:26:09,360 Speaker 1: more heavily on just the uh integrated audio that's on motherboards. 427 00:26:09,680 --> 00:26:11,359 Speaker 1: The reason I bring this up at all is because 428 00:26:11,400 --> 00:26:14,239 Speaker 1: if you read the articles by Jake Simpson, they go 429 00:26:14,280 --> 00:26:17,920 Speaker 1: into some detail about sending audio to computer hardware. That's 430 00:26:17,920 --> 00:26:20,600 Speaker 1: a little bit dated because again those articles came out 431 00:26:20,640 --> 00:26:23,280 Speaker 1: in two thousand two, but game engines still have to 432 00:26:23,280 --> 00:26:25,879 Speaker 1: be able to set rules for all of those sound 433 00:26:26,040 --> 00:26:29,639 Speaker 1: elements today. So, for example, let's say you're playing a 434 00:26:29,680 --> 00:26:33,560 Speaker 1: stealth based game, and audio is really important to this 435 00:26:33,680 --> 00:26:37,159 Speaker 1: kind of gameplay. You're playing a character that's trying to 436 00:26:37,240 --> 00:26:41,600 Speaker 1: stay out of view, You're sneaking around. You need to 437 00:26:41,600 --> 00:26:46,320 Speaker 1: be able to hear where other characters, monsters whatever it 438 00:26:46,359 --> 00:26:50,200 Speaker 1: may be, are in relation to your location so that 439 00:26:50,280 --> 00:26:54,439 Speaker 1: you don't give away your presence, and the quality of 440 00:26:54,480 --> 00:26:57,520 Speaker 1: audio you here should depend on lots of other factors, 441 00:26:57,520 --> 00:27:01,960 Speaker 1: such as is the other character Let's say, are they 442 00:27:01,960 --> 00:27:03,880 Speaker 1: in the same space that you are in are then 443 00:27:04,000 --> 00:27:06,000 Speaker 1: are they in the same room? Are they in a 444 00:27:06,080 --> 00:27:09,400 Speaker 1: room next door? Is there a wall or door between you? 445 00:27:10,080 --> 00:27:13,000 Speaker 1: Because if there is, that should maybe muffle the sound 446 00:27:13,040 --> 00:27:16,639 Speaker 1: a bit. You shouldn't hear a person who's in a 447 00:27:16,800 --> 00:27:19,720 Speaker 1: room over and there's a big wooden door between you. 448 00:27:19,720 --> 00:27:21,440 Speaker 1: You shouldn't be able to hear them as if they're 449 00:27:21,480 --> 00:27:24,320 Speaker 1: standing right next to you talking clear as day. You 450 00:27:24,320 --> 00:27:27,520 Speaker 1: should hear a muffled sound. Maybe you can't even quite 451 00:27:27,600 --> 00:27:30,679 Speaker 1: make out what's being said. Or let's say that you 452 00:27:30,720 --> 00:27:34,359 Speaker 1: are sneaking around in an area that's got water and 453 00:27:34,400 --> 00:27:38,840 Speaker 1: you're you're you're going under the water. The sound should 454 00:27:38,840 --> 00:27:41,520 Speaker 1: be different when you're underwater. You should have that that 455 00:27:41,640 --> 00:27:46,359 Speaker 1: kind of muffled effect. Again, you wouldn't expect it to 456 00:27:46,480 --> 00:27:50,840 Speaker 1: sound like someone's right there next to you. You might 457 00:27:50,880 --> 00:27:54,240 Speaker 1: want to have effects like echo involved or reverb, something 458 00:27:54,280 --> 00:27:57,919 Speaker 1: like that. The game engine can apply those effects to 459 00:27:58,080 --> 00:28:04,280 Speaker 1: the same audio assets based upon the actual uh context 460 00:28:04,400 --> 00:28:07,280 Speaker 1: of the game at that moment. So if you're playing 461 00:28:07,520 --> 00:28:09,960 Speaker 1: one way, Let's say you're playing the exact same level, 462 00:28:10,000 --> 00:28:12,560 Speaker 1: but you're playing it in two very different ways, and 463 00:28:12,600 --> 00:28:18,240 Speaker 1: in one way, you're sneaking underground underneath a surface where 464 00:28:18,280 --> 00:28:21,400 Speaker 1: people are walking around, you would hear things differently than 465 00:28:21,440 --> 00:28:24,040 Speaker 1: if you played it a second way and you're sneaking 466 00:28:24,280 --> 00:28:27,000 Speaker 1: through that room where you're actually going into the room 467 00:28:27,000 --> 00:28:29,040 Speaker 1: where other people are, you would be able to hear 468 00:28:29,080 --> 00:28:31,600 Speaker 1: things much more differently. And the game engine should be 469 00:28:31,680 --> 00:28:35,679 Speaker 1: able to interpret that information and present it properly because 470 00:28:35,720 --> 00:28:39,160 Speaker 1: it's applying the rules based upon its understanding of where 471 00:28:39,160 --> 00:28:41,720 Speaker 1: the player is in relation to the other assets in 472 00:28:41,760 --> 00:28:44,720 Speaker 1: the game. Some game engines allow developers to import a 473 00:28:44,880 --> 00:28:48,320 Speaker 1: map into the game engine itself, and then the engine 474 00:28:48,320 --> 00:28:52,400 Speaker 1: will overlay what is essentially a sound map on top 475 00:28:52,520 --> 00:28:55,640 Speaker 1: of the physical map of the game level. The sound 476 00:28:55,640 --> 00:28:59,080 Speaker 1: map indicates which effects should apply to sounds in various 477 00:28:59,120 --> 00:29:03,240 Speaker 1: spots depending upon player location, and that can include areas 478 00:29:03,240 --> 00:29:05,880 Speaker 1: where the nature of sound will change as the player 479 00:29:05,960 --> 00:29:09,800 Speaker 1: character moves through an environment, so you get dynamics. In 480 00:29:09,800 --> 00:29:13,360 Speaker 1: other words, you might be jumping off the side of 481 00:29:13,400 --> 00:29:16,240 Speaker 1: a cliff and you hear someone yelling after you, and 482 00:29:16,520 --> 00:29:19,400 Speaker 1: their voice might change as you're falling away and change 483 00:29:19,440 --> 00:29:22,360 Speaker 1: even more. Let's say you plunge into a lake and 484 00:29:22,400 --> 00:29:25,200 Speaker 1: it changes even more when you go under water. That 485 00:29:25,280 --> 00:29:29,200 Speaker 1: stuff is possible because of the logic the game engines 486 00:29:29,360 --> 00:29:33,479 Speaker 1: used to manipulate these assets. A game engine also typically 487 00:29:33,520 --> 00:29:37,080 Speaker 1: includes instructions The game needs to accept inputs from control 488 00:29:37,080 --> 00:29:42,280 Speaker 1: mechanisms so that the player can actually take control of 489 00:29:42,320 --> 00:29:44,440 Speaker 1: whatever it is they're playing in the game. That can 490 00:29:44,480 --> 00:29:47,920 Speaker 1: include stuff like a joystick, or a mouse and keyboard, 491 00:29:48,000 --> 00:29:50,320 Speaker 1: or a game pad, a steering wheel, those sort of 492 00:29:50,320 --> 00:29:54,400 Speaker 1: peripheral devices. The two main methods of handling input are 493 00:29:54,440 --> 00:29:58,960 Speaker 1: called events and polling. So with the events approach, the 494 00:29:59,080 --> 00:30:03,240 Speaker 1: game engine text incoming input signals like if you hit 495 00:30:03,360 --> 00:30:05,680 Speaker 1: a button on a game pad or you pull a 496 00:30:05,680 --> 00:30:08,920 Speaker 1: trigger on a joystick. That incoming signal then activates a 497 00:30:08,960 --> 00:30:12,920 Speaker 1: custom code that is mapped to that input. So the 498 00:30:13,000 --> 00:30:16,080 Speaker 1: custom code might say every time the player pulls the 499 00:30:16,080 --> 00:30:19,240 Speaker 1: trigger on a joystick, it's mapped with a command for 500 00:30:19,520 --> 00:30:23,360 Speaker 1: fire the main weapon. The polling is used to monitor 501 00:30:23,440 --> 00:30:27,200 Speaker 1: position values, like the position of a joystick, whether it's 502 00:30:27,200 --> 00:30:30,960 Speaker 1: in neutral position where it's centered, or it is being 503 00:30:31,000 --> 00:30:33,720 Speaker 1: pushed forward or pulled back or moved from one side 504 00:30:33,760 --> 00:30:36,200 Speaker 1: to the other, or the same thing for the position 505 00:30:36,240 --> 00:30:40,160 Speaker 1: of a thumbstick or for the relative x y position 506 00:30:40,200 --> 00:30:44,200 Speaker 1: of a mouse. As you move these different devices around, 507 00:30:44,280 --> 00:30:48,040 Speaker 1: that changes that positional value associated with that device, and 508 00:30:48,080 --> 00:30:51,040 Speaker 1: again that gets mapped to an appropriate action within the game, 509 00:30:51,200 --> 00:30:54,280 Speaker 1: such as your character turns or moves forward or backward 510 00:30:54,360 --> 00:30:57,240 Speaker 1: or whatever it might be. One of the biggest challenges 511 00:30:57,280 --> 00:31:00,640 Speaker 1: of modern games is online play. It pretty much a 512 00:31:00,720 --> 00:31:03,080 Speaker 1: standard for most games these days, and in fact, more 513 00:31:03,080 --> 00:31:06,400 Speaker 1: and more games are acquiring a persistent online connection to 514 00:31:06,480 --> 00:31:08,240 Speaker 1: even play them at all, even if it's just a 515 00:31:08,280 --> 00:31:13,160 Speaker 1: single player game. But incorporating online elements introduces a ton 516 00:31:13,360 --> 00:31:16,760 Speaker 1: of other problems that would be show stoppers if programmers 517 00:31:16,760 --> 00:31:19,880 Speaker 1: had to solve for them manually with every single game. So, 518 00:31:19,960 --> 00:31:23,160 Speaker 1: for example, uh, well, the nature of traffic across the 519 00:31:23,200 --> 00:31:27,880 Speaker 1: Internet by itself creates tons of potential problems from latency, 520 00:31:28,000 --> 00:31:30,360 Speaker 1: which is the lag between when you send a command 521 00:31:30,480 --> 00:31:34,400 Speaker 1: and when it gets executed, two dropped packets which can 522 00:31:34,440 --> 00:31:37,160 Speaker 1: create errors. So when you think about it, it's actually 523 00:31:37,200 --> 00:31:41,600 Speaker 1: pretty amazing that we can have online simultaneous play between 524 00:31:41,680 --> 00:31:44,840 Speaker 1: multiple players within the same game. If you're in a 525 00:31:44,920 --> 00:31:48,600 Speaker 1: multiplayer game, let's say you're playing something like Overwatch, for example, 526 00:31:49,160 --> 00:31:53,440 Speaker 1: every character you see on screen represents another human player 527 00:31:53,840 --> 00:31:57,200 Speaker 1: playing that game somewhere else in the world, but your 528 00:31:57,280 --> 00:32:00,239 Speaker 1: instance of the video game, the game you see on 529 00:32:00,320 --> 00:32:03,640 Speaker 1: your system, has to create the image and make sure 530 00:32:03,680 --> 00:32:07,480 Speaker 1: it reflects the proper position and orientation of every other 531 00:32:07,840 --> 00:32:13,000 Speaker 1: player's character. So if I'm facing down Reaper and Overwatch 532 00:32:13,400 --> 00:32:16,560 Speaker 1: and Reaper's back is to me, Reaper should not be 533 00:32:16,640 --> 00:32:19,440 Speaker 1: able to shoot me. I should be confident that the 534 00:32:19,440 --> 00:32:23,320 Speaker 1: player controlling Reaper can't see me because the character has 535 00:32:23,360 --> 00:32:26,440 Speaker 1: turned away from me. But this requires my instance of 536 00:32:26,440 --> 00:32:30,400 Speaker 1: the game to render Reaper accurately, even with those challenges 537 00:32:30,440 --> 00:32:33,640 Speaker 1: I mentioned earlier. For that reason, game engines tend to 538 00:32:33,680 --> 00:32:37,360 Speaker 1: have components that handle the online communication aspects of a game, 539 00:32:37,600 --> 00:32:40,440 Speaker 1: so that game developers can focus on creating the assets 540 00:32:40,440 --> 00:32:42,400 Speaker 1: that make the game special in the first place, but 541 00:32:42,480 --> 00:32:47,520 Speaker 1: not worry about handling all that Internet communications nonsense. Artificial 542 00:32:47,520 --> 00:32:52,080 Speaker 1: intelligence is another component that can be incorporated partly into 543 00:32:52,160 --> 00:32:55,600 Speaker 1: a game engine. Typically this would involve using a third 544 00:32:55,640 --> 00:32:59,280 Speaker 1: party path finding solution. I'd go into more detail on 545 00:32:59,320 --> 00:33:02,720 Speaker 1: this one, but I'm running along, and also it starts 546 00:33:02,720 --> 00:33:04,600 Speaker 1: to get over my head pretty darn quickly, if I'm 547 00:33:04,600 --> 00:33:09,040 Speaker 1: being honest. But one interesting example I want to point 548 00:33:09,040 --> 00:33:13,000 Speaker 1: out of how AI can go awry and how pathfinding 549 00:33:13,040 --> 00:33:16,200 Speaker 1: can become a problem is a game that came out 550 00:33:16,240 --> 00:33:19,520 Speaker 1: in two thousand and thirteen. It's called Aliens Colonial Marines. 551 00:33:19,560 --> 00:33:21,000 Speaker 1: A lot of you may have heard of this game. 552 00:33:21,320 --> 00:33:25,000 Speaker 1: When it came out, critics and gamers alike complained that 553 00:33:25,120 --> 00:33:28,040 Speaker 1: the game was buggy and that the enemies would behave 554 00:33:28,080 --> 00:33:31,320 Speaker 1: in really weird ways. They get stuck in levels, they 555 00:33:31,360 --> 00:33:35,160 Speaker 1: would all just not behave in a very strategic manner. 556 00:33:35,200 --> 00:33:37,520 Speaker 1: They would just kind of rush at the player and 557 00:33:37,600 --> 00:33:40,800 Speaker 1: a mode. While exploring the game's code, discovered that in 558 00:33:41,000 --> 00:33:44,320 Speaker 1: one of the initialization files for the game, there was 559 00:33:44,360 --> 00:33:47,000 Speaker 1: a typo. There was a line of code that was 560 00:33:47,040 --> 00:33:51,200 Speaker 1: meant to attach AI components to a specific points on 561 00:33:51,240 --> 00:33:53,960 Speaker 1: a map. They called it tethering, and it would give 562 00:33:53,960 --> 00:33:56,880 Speaker 1: the AI the ability to behave in a tactical way 563 00:33:57,080 --> 00:34:00,920 Speaker 1: within certain sectors or tethers of a level. But in 564 00:34:00,960 --> 00:34:04,800 Speaker 1: this line of code, the word tether t E t 565 00:34:05,400 --> 00:34:08,600 Speaker 1: h E R had a superfluous A. In it, it 566 00:34:08,680 --> 00:34:11,880 Speaker 1: was spelled as t e A t h e R, 567 00:34:12,040 --> 00:34:15,600 Speaker 1: almost like heather, and that was a typo. Removing the 568 00:34:15,719 --> 00:34:20,040 Speaker 1: A using just a regular editor program and then executing 569 00:34:20,080 --> 00:34:23,440 Speaker 1: the game again created an experience more like what the 570 00:34:23,440 --> 00:34:27,360 Speaker 1: developers had intended, with AI suddenly becoming more of a 571 00:34:27,400 --> 00:34:29,840 Speaker 1: threat to the player being able to behave in a 572 00:34:29,840 --> 00:34:33,040 Speaker 1: more strategic way. It didn't solve all the problems that 573 00:34:33,280 --> 00:34:36,520 Speaker 1: game had, but it definitely solved a big one. So 574 00:34:36,960 --> 00:34:40,400 Speaker 1: the game engine in this case was performing properly the 575 00:34:40,400 --> 00:34:43,320 Speaker 1: whole time. It was just because there was a typo 576 00:34:43,400 --> 00:34:46,160 Speaker 1: in the code that was being executed in the game 577 00:34:46,160 --> 00:34:49,400 Speaker 1: engine that the problem was happening at all. Then we 578 00:34:49,440 --> 00:34:52,760 Speaker 1: finally have a physics engines. These are components that determine 579 00:34:52,760 --> 00:34:56,839 Speaker 1: the physical rules within the virtual world. So, if you're 580 00:34:56,880 --> 00:34:59,440 Speaker 1: talking about a first person shooter, if you drop a weapon, 581 00:34:59,640 --> 00:35:03,120 Speaker 1: does it fall to the ground? If so, how fast? 582 00:35:03,239 --> 00:35:07,000 Speaker 1: How strong is gravity? Does it float away? How far 583 00:35:07,160 --> 00:35:10,719 Speaker 1: can you jump? How fast can you run? How far 584 00:35:10,760 --> 00:35:14,879 Speaker 1: can you fall without taking any damage? If you knock 585 00:35:14,920 --> 00:35:19,600 Speaker 1: out an opponent, does the opponent disappear? Do they flop 586 00:35:19,680 --> 00:35:22,640 Speaker 1: realistically like a rag doll? Does have the rag Doll 587 00:35:22,719 --> 00:35:26,239 Speaker 1: physics that became really popular ballad decade ago and are 588 00:35:26,239 --> 00:35:29,600 Speaker 1: still popular today. These sorts of things and more, including 589 00:35:29,600 --> 00:35:32,560 Speaker 1: how effects behave in different environments, all depend upon the 590 00:35:32,600 --> 00:35:35,640 Speaker 1: physics engine, and this is also the main part of 591 00:35:35,640 --> 00:35:38,600 Speaker 1: the engine that determines things like collision detection and what 592 00:35:38,680 --> 00:35:42,120 Speaker 1: happens if two virtual objects actually make contact within the game, 593 00:35:42,840 --> 00:35:46,200 Speaker 1: or how a solid stiff object moves through a space 594 00:35:46,480 --> 00:35:51,200 Speaker 1: as opposed to a more Bindi floppy object. So there 595 00:35:51,200 --> 00:35:53,319 Speaker 1: are a lot of off the shelf physics engines out 596 00:35:53,320 --> 00:35:55,480 Speaker 1: there that you can plug into a game engine, just 597 00:35:55,600 --> 00:35:58,040 Speaker 1: as there are off the shelf tools for building in 598 00:35:58,200 --> 00:36:01,960 Speaker 1: game models. UH. The physics engines have names like Havoc, 599 00:36:02,080 --> 00:36:04,520 Speaker 1: which started out as a physics engine component from an 600 00:36:04,520 --> 00:36:09,120 Speaker 1: Irish company. Now it's owned by Microsoft. UH. There's other ones. 601 00:36:09,200 --> 00:36:12,560 Speaker 1: There's like Newton Game Dynamics that's an open source physics engine, 602 00:36:12,560 --> 00:36:15,600 Speaker 1: but there there's several out there on the market. Physics 603 00:36:15,640 --> 00:36:18,440 Speaker 1: engines use lots of different techniques to create or simulate 604 00:36:18,480 --> 00:36:20,880 Speaker 1: real world physics in a virtual world, and just like 605 00:36:20,920 --> 00:36:24,360 Speaker 1: game engines, there's not just a single way to achieve 606 00:36:24,400 --> 00:36:26,640 Speaker 1: this goal. There are lots of different approaches, but they 607 00:36:26,640 --> 00:36:30,200 Speaker 1: all try to do the same thing, they just try 608 00:36:30,239 --> 00:36:33,319 Speaker 1: to do it in different ways. And there's so much 609 00:36:33,360 --> 00:36:37,200 Speaker 1: more I could go into, like the graphic user interface 610 00:36:37,239 --> 00:36:41,200 Speaker 1: design for the game or the scripting process for developers 611 00:36:41,239 --> 00:36:46,640 Speaker 1: where outcomes will occur when certain triggers are hit. But 612 00:36:46,760 --> 00:36:49,680 Speaker 1: you get the idea. I think the game engine is 613 00:36:49,719 --> 00:36:54,840 Speaker 1: the facilitator that ultimately translates the content that developers have 614 00:36:54,920 --> 00:36:59,239 Speaker 1: created into meaningful information for a computer system, so that 615 00:36:59,320 --> 00:37:02,480 Speaker 1: the right stuff off happens at the right time, at 616 00:37:02,560 --> 00:37:08,520 Speaker 1: least ideally. Sometimes just bad code makes bad things happen. 617 00:37:09,040 --> 00:37:10,680 Speaker 1: And there are a lot of different game engines out 618 00:37:10,719 --> 00:37:12,680 Speaker 1: there in the wild. Here are a few notable ones. 619 00:37:13,160 --> 00:37:15,960 Speaker 1: I opened the show talking about Doom. While the ID 620 00:37:16,000 --> 00:37:19,880 Speaker 1: Tech game engine is still being used largely by independent 621 00:37:19,880 --> 00:37:23,480 Speaker 1: game developers, but others as well. The Unreal Engine is 622 00:37:23,480 --> 00:37:25,840 Speaker 1: one of the most famous game engines out there. It 623 00:37:25,880 --> 00:37:28,960 Speaker 1: was created by Epic Games. It's named after the Unreal 624 00:37:29,040 --> 00:37:32,200 Speaker 1: Tournament series of shooter games, but it's been used for 625 00:37:32,360 --> 00:37:35,000 Speaker 1: tons of other games to including stuff like Gears of 626 00:37:35,040 --> 00:37:38,879 Speaker 1: War and Mass Effect. Unity three D is another big 627 00:37:38,920 --> 00:37:41,719 Speaker 1: game engine that one's from Unity Technologies. It's used by 628 00:37:41,760 --> 00:37:44,960 Speaker 1: a lot of independent and mobile games. The Cry engine 629 00:37:45,640 --> 00:37:48,520 Speaker 1: was developed by cry Tech for games like far Cry 630 00:37:49,120 --> 00:37:51,759 Speaker 1: e A Dice uses a game engine called frost Bite 631 00:37:51,800 --> 00:37:55,040 Speaker 1: as the foundation for games like Battlefield. Other developers have 632 00:37:55,120 --> 00:37:58,319 Speaker 1: their own proprietary game engines. For example, rock Star, which 633 00:37:58,360 --> 00:38:01,160 Speaker 1: makes the Grand Theft Auto and Red Dead Redemption series, 634 00:38:01,560 --> 00:38:05,360 Speaker 1: uses the rock Star Advanced Game Engine or RAGE to 635 00:38:05,520 --> 00:38:09,720 Speaker 1: power its games. Insomniac Games created a special game engine 636 00:38:09,760 --> 00:38:13,000 Speaker 1: for their title Sunset Overdrive, and then used a modified 637 00:38:13,080 --> 00:38:15,719 Speaker 1: version of that game engine for the recent Spider Man 638 00:38:15,760 --> 00:38:19,480 Speaker 1: game for the PS four. Now. Ultimately, these game engines 639 00:38:19,520 --> 00:38:22,520 Speaker 1: create an environment so that developers can focus on those 640 00:38:22,560 --> 00:38:26,000 Speaker 1: elements that define a game without having to fuss over 641 00:38:26,040 --> 00:38:30,279 Speaker 1: the minute mathematical details. The game engine handles all of that. 642 00:38:30,800 --> 00:38:34,160 Speaker 1: So I hope that is a good overview of what 643 00:38:34,239 --> 00:38:37,600 Speaker 1: game engines are and how they work from uh, from 644 00:38:37,640 --> 00:38:43,160 Speaker 1: a a basic standpoint. Obviously, getting deep into it would 645 00:38:43,200 --> 00:38:47,120 Speaker 1: require a whole series of episodes getting very technical and 646 00:38:47,239 --> 00:38:50,319 Speaker 1: very specific, because again, different game engines do this in 647 00:38:50,360 --> 00:38:53,680 Speaker 1: different ways. But it is a fascinating topic and hopefully 648 00:38:53,719 --> 00:38:55,480 Speaker 1: that lets you know a little bit more about what 649 00:38:55,520 --> 00:38:57,919 Speaker 1: it means when someone talks about a game engine and 650 00:38:58,480 --> 00:39:02,040 Speaker 1: what it does, and whether it's a good game engine 651 00:39:02,120 --> 00:39:03,960 Speaker 1: or a bad game engine. You understand a little bit 652 00:39:03,960 --> 00:39:06,960 Speaker 1: more of where that's coming from. If you guys have 653 00:39:07,000 --> 00:39:10,000 Speaker 1: any suggestions for future episodes of tech Stuff, maybe it's 654 00:39:10,040 --> 00:39:13,160 Speaker 1: a technology, a company, person in tech. Maybe there's someone 655 00:39:13,239 --> 00:39:16,560 Speaker 1: I should interview or have on as a guest. Let 656 00:39:16,560 --> 00:39:19,600 Speaker 1: me know, send me your suggestions. The email address for 657 00:39:19,640 --> 00:39:23,360 Speaker 1: the show is tech Stuff at how stuff works dot com, 658 00:39:23,480 --> 00:39:25,960 Speaker 1: or drop me a line on Facebook or Twitter. The 659 00:39:26,000 --> 00:39:28,480 Speaker 1: handle of both of those for the show is text 660 00:39:28,520 --> 00:39:31,919 Speaker 1: stuff H s W. Don't forget. You can go over 661 00:39:31,960 --> 00:39:35,200 Speaker 1: to T public dot com slash tech stuff. That's T 662 00:39:35,520 --> 00:39:38,560 Speaker 1: E E public dot com slash tech Stuff. That's where 663 00:39:38,560 --> 00:39:41,160 Speaker 1: we have all of our merch. You guys really like 664 00:39:41,280 --> 00:39:44,600 Speaker 1: the code like a girl T shirts and so do I. 665 00:39:44,600 --> 00:39:47,080 Speaker 1: I love that one. But we have tons of other 666 00:39:47,080 --> 00:39:50,160 Speaker 1: stuff on there, including our tech Stuff capture shirt, prove 667 00:39:50,280 --> 00:39:53,200 Speaker 1: that You're not a robot and more. So go check 668 00:39:53,239 --> 00:39:57,319 Speaker 1: those out and follow us on Instagram and uh yes, 669 00:39:57,840 --> 00:40:01,640 Speaker 1: that's it. I'm done. I'll talk to you again really 670 00:40:01,719 --> 00:40:10,480 Speaker 1: soon for more on this and thousands of other topics. 671 00:40:10,719 --> 00:40:21,920 Speaker 1: Is it how stuff Works dot com