Video games graphics are more and more pretty and realistic
and this is thanks to many tricks
that developers use to have us believe that they've built a huge, detailed and realistic world.
We'll find out about some of those tricks in this video.
Whether you're a gamer or not, this will change the way you think about video games.
As realistic as a video game may appear,
if you compare it with animated films or even special effects,
the quality is still very far behind.
Why is that the case?
There's a very big difference between video games and animated films,
especially concerning image computing time.
At this point, the average time it takes to generate one animated film image is 15 hours.
For one image?
In video games you want each image to be dynamic.
Some games will run on 30 fps (frames per second) or 60 fps.
For a 30 fps game, the computer calculates a new image every 33 ms,
and for a 60 fps game that'll be every 16 ms.
For animated films, several hundreds of computers take care of calculating each image,
whereas a video game image is computed by a single console
so we're limited by their physical characteristics.
So the challenge is to generate the nicest possible image in a short amount of time,
and I'm guessing there are tricks to help you do that?
Sure, one of them is to only compute what you're showing on the screen.
So right now there's a whole world behind me and I can't not show that,
whereas in a game, you don't show whatever is behind the character.
It's only when the player turns around that we begin to compute what's behind the character.
So that was about what you don't see, but there's also a lot of stuff that you do see.
This setting's easy, indoors with close objects -
but outside, the city's huge:
you have to show the bin, the table and the lamppost which are all far away.
We do want to show every item in this scene,
and the way we do it is by using different levels of detail
depending on how far the object is from the character/camera.
So you can see the lamp post over there pretty well,
but if you get closer you can see it in a lot more detail.
From all the way over there, the shape of the lamppost is very simple.
When you get closer, the level of detail increases a lot
and then you add lots of textures that'll make it look nicer.
But this means that we're asking for a lot more calculations
and that's a lot more costly.
I'm trying to think of all the things we could just not bother with in order to avoid those calculations.
These cobblestones, for instance.
It must be hell to recreate every small detail on every individual stone.
Why don't you always go for flat grounds?
We have another trick for this.
We do use a flat layer,
but then we apply several textures to it.
It's a bit like a complex wallpaper.
The reason why you see a difference in depth on these stones
is that the photons reflected from this point don't reach your eyes in the same way
as the photons reflected from that point.
So we'll use one texture layered over another for the colours
and that'll define how the photons will bounce off of the texture for a given point.
That'll be the job of one specific texture.
The angle at which the photons bounce is called the normal.
Is there anything other than the images that you play with to optimize computation time?
Yes, in animations for instance,
which are currently the most costly things to create in video games.
The trick is to play with the distances between the items you present.
For a moving character set far away from yours,
you'll play with the quality of the animation,
so it might be a bit jerky
or the calculations will be less precise in order to save on computation time.
How do you make your calculations less precise?
Basically it's about not paying too much attention to, say, hands being at the right spot.
So you can let them pass through a door or something,
the character is far away so you don't need a huge amount of detail.
So if you need to do a division,
you can afford to round up a lot earlier on.
One division takes several iterations,
it's one of the more costly operations you can ask the computer to do.
It'll take several iterations depending on how precise you want your calculations to be.
So once you lower your precision threshold, your calculations are a lot less heavy.
Do you have any other examples?
Say you need one character to shoot another.
You'll need to check that the angle is right
so if you know that a certain gun should give you an angle of 20°
you can pre-calculate the cosine of 20 based off of that assumption.
Right so instead of calculating the cosine of 20,
you'll add the result of that calculation directly into your code?
That's right.
We also use a classic, Pythagoras' Theorem.
The one we learn in school that says that c²=a²+b².
And then you'd take the square root of that in order to find c.
In order to find out the distance between two characters in one scene
we compare the squared distances instead of bothering with the square root.
So we work with squared distances.
Okay, so instead of calculating c you just stick with c² so you don't have to compute the square root.
I was never a gamer myself and I never owned a proper gaming PC,
but whenever I did play, the computer would lag quite a bit
so what's there to be fixed, how come it lags so much?
There's a lot of calculations to be done.
And we choose to do the calculations first and then show the images,
rather than break in the middle of a calculation.
There's a physical quality too, not just visual quality.
For instance sound quality matters too.
And we can't lower the physical quality of the game
according to the machine's performance
because we can't allow an item to randomly fall through the ground,
that would completely spoil the gaming experience.
So when you decrease the quality of a video game,
you decrease its overall quality,
including the calculations that hold your world together.
Thanks a lot Yannick, my appreciation of video games has definitely increased
and I might even try to play something other than the Minesweeper game.
I've got a great score on that though!
Thank you so much for watching this video, I hope you liked it!
This video was actually sponsored by the Vlogbrothers,
whom I respect a lot, they work hard to bring science and cultural things online.
They're part of the English speaking part of YouTube if you don't know them,
and it's an honour having this video sponsored by them
so thank you so much.