
GTA V – Graphics Study - franzb
http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphics-study/
======
gdubs
Really neat to see a big hairy problem broken up into so many small chunks.
Multi-pass rendering, level of detail culling, soft-shadow blurring. It
reminds me of the Arthur C. Clark quote that "Any sufficiently advanced
technology is indistinguishable from magic". There's a phenomenal amount of
processing steps happening here, on a frame-by-frame basis. I feel old
thinking of how many hours this type of rendering took running 3D Studio Max
back in 2002 on a _network_ of Windows NT boxes.

~~~
bd
Yup, modern game engines are complex systems with many parts.

Getting nearer to photorealistic graphics [1] isn't just about doing "more of
the same and faster" (Moore's Law), it's increasingly also about "division of
labor" across many subcomponents.

I like this rendering passes breakdown for Battlefield 4 (there are 54
passes):

[http://imgur.com/N4gJkbm](http://imgur.com/N4gJkbm)

(Frostbite engine by DICE, started as Battlefield franchise backbone, now it's
becoming _the_ engine for EA, sharing tech across many games - Battlefield,
Dragon Age, Mass Effect, Need for Speed, Star Wars: Battlefront, Mirror's
Edge)

\-----

[1] See e.g. here how close to photo sources Frostbite engine can get today
(latest Need for Speed game):

[http://static1.gamespot.com/uploads/original/1539/15391776/2...](http://static1.gamespot.com/uploads/original/1539/15391776/2909917-2479418915-Qt2s3.jpg)

~~~
LesZedCB
I will say it took me an uncomfortably long time to determine which pictures
were real. The pavement is a pretty good giveaway, but incredible nonetheless.

~~~
Keyframe
Yeah, they got really good. For the rest - two pictures on the left are from
the game engine and two pictures on the right are photographs.

------
corysama
This is the third game that the author has dissected. The previous two are
also very nice :)

[http://www.adriancourreges.com/blog/2015/06/23/supreme-
comma...](http://www.adriancourreges.com/blog/2015/06/23/supreme-commander-
graphics-study/)

[http://www.adriancourreges.com/blog/2015/03/10/deus-ex-
human...](http://www.adriancourreges.com/blog/2015/03/10/deus-ex-human-
revolution-graphics-study/)

~~~
MasterScrat
How does he know so much about the engine internals? Reverse-engineering?

~~~
lispit
He used Renderdoc, which lets you pick a frame apart draw call by draw call,
inspect shader bytecode, etc.

[https://github.com/baldurk/renderdoc](https://github.com/baldurk/renderdoc)

------
shinymark
I love computer science and have been attracted to all aspects of it for
years. But I still continue to gravitate towards games and this article
reminds me of why. Thank you to the author.

Practical application of cutting edge graphics tech to both make a beautiful
image and create an immersive world is so compelling to me. I also really like
the tight visual/audio iteration loop games provide for day to day work. It's
incredibly rewarding to me to conceptualize how to solve a problem and have a
playable prototype in the next few hours that a real player can test.

I can imagine myself working in various fields but I'm always drawn back to
games for better or worse. While it's just as likely as a developer you'll
incite gamer rage with some small mishap there is also the opportunity to make
a piece of entertainment people love and remember. That's the goal I keep
striving for in my work.

~~~
Impossible
It's nice to see an honest, positive post about the game industry on HN.

------
johntb86
> "I believe this mode is used for meshes very far away or transitioning
> between LOD levels, it allows to save on fillrate and shading calculation by
> discarding certain pixels."

I think this is a better answer for why they use checkerboarding:
[http://gamedev.stackexchange.com/questions/47844/why-are-
som...](http://gamedev.stackexchange.com/questions/47844/why-are-some-games-
using-some-dithering-pattern-instead-of-traditional-alpha-for)

Summary: Alpha doesn't work in deferred shading, so they use screendoor
transparency instead.

~~~
bd
Yup, Witcher 3 does the same thing (thanks to that GameDev StackExchange link
it finally clicked for me why Witcher 3 has that dithered look when moving
around).

In case it still isn't clear after reading both descriptions of what's going
on: that method and a bit weird look comes from using transparency via
dithering/checkerboarding when doing LOD levels transitions in deferred
rendering pipeline.

When rendering levels-of-details, you need to render both higher-level and
lower-level quality models at the same time and blend between both, not to
have sudden visual discontinuities.

In deferred pipeline transparencies are tricky / costly, so doing dithering is
a clever workaround, basically piercing holes in a opaque solid models.

This would be quite ugly for regular transparent surfaces like glass /
windshield / water, so those are rendered in a different way (usually forward
pass).

But for LOD transitions, which are short in duration, it can look quite
acceptable (imagine superimposed images of two versions of one tree, one low-
poly model, one high-poly model, further away you are from the tree, more
pixels of low-poly tree you see).

------
bigdubs
This is a great breakdown even for a novice who doesn't know much about how
rendering engines typically function.

It gives me a new appreciation for games, the amount of work and creativity
that goes into the final experience for the player.

~~~
strayptr
_This is a great breakdown even for a novice who doesn 't know much about how
rendering engines typically function._

What would you like to know? I have some time, so if anyone was hoping to
learn more about this, ask me.

~~~
omginternets
The only graphics programming I've ever done has been with pygame.

What should I read next?

~~~
strayptr
This domain is unique in that it's not a good idea to read. The most effective
way to navigate this territory seems to be: Think of a simple goal, then force
yourself to solve it. Don't look up how to solve it until you're so frustrated
that you want to throw your monitor across your room.

Actionable advice: Set up a program such that you have an array of pixels.
Say, 512x512. Now write a while loop which randomizes those pixels. Finally,
figure out some way to "create a window and put those pixels on the screen."

You now have a game loop. This is roughly how every game works at a basic
level.

The next step is to realize that a triangle is the fundamental way to draw
shapes quickly. Want to draw a square? That's two triangles. Want to draw a
humanoid? Sounds complicated, but artists approximate humanoids with a
combination of spheres, cylinders, cubes, etc. And all of those can be divided
up into triangles.

So a triangle is therefore the first place to start in understanding graphics
in general. What's the goal? "Create a data structure to represent a triangle.
Now try to draw a white triangle into your little pixel array."

It's going to be tough. But tough work is good. I remember how difficult it
was for me to even get a basic white triangle up on the screen. But the
rewards are worthwhile, because at this point a lot of other things will start
to click. A "vertex buffer" will no longer be mysterious, for example, because
you'll immediately see that your triangle structure (whatever you came up
with) was really just "a vertex buffer with three vertices." And then you'll
start to wonder why graphics programmers came up with such complicated words
to describe such simple concepts...

At this point, you'll have the ability to go in one of two directions: "Notch"
or "Carmack." It depends entirely on what you find interesting. If you like
the idea of making games, concentrate on creating Pong. (You have everything
you need, because you just got a triangle up on the screen, after all.) If you
like more along the lines of what the article talks about, then concentrate on
creating a software rasterizer. "Software rasterizer" is another one of those
terms that turn out to sound scary, but is way easier than you'd expect. It's
hard in the same way that learning to ride a bike is hard: it'll take awhile,
but you'll never forget it. After that, nothing else you ever do (in graphics)
will ever seem even slightly mysterious. I have some thoughts on how to learn
the latter, if anyone's interested.

~~~
ska

       This domain is unique in that it's not a good idea to read.
    

crazy talk.

Sure, learn by doing; but there are great resources to help you understand
far, far faster than you ever will by experimenting alone. If nothing else,
there is good code to read, and classic texts.

~~~
strayptr
Mmhm. As with everything, it's a balance. It's important to understand that
reading is one of the most effective forms of procrastination that has ever
been invented. It's also the prism through which your entire future passes,
but everyone already knows that.

For example, Carmack was able to "invent" BSP because he was (as far as I've
heard) an avid reader of medical journals. Specifically, journals and papers
about the graphics techniques they used at the time. The field of medicine
turns out to be very lucrative for an ambitious graphics programmer, because
they're often at the frontiers of what's currently possible. So apparently BSP
was used in accelerating medical renderings, and Carmack was able to see their
potential for realtime graphics. The only reason he was able to do that was by
reading pretty much every possible thing.

None of that will help you unless you force yourself to _do_ and not read,
though.

~~~
ska
You stated "This domain is unique in that it's not a good idea to read."

This is just not true in either of its claims. It's not even useful hyperbole,
really, it's just wrong.

Graphics programming is _exactly_ like other domains of technical development,
you will learn best by a combination of reading good summaries/examples of
what is known, doing work on your own (not cutting corners), and talking to
people that know more about that you do.

~~~
strayptr
And yet, if you proceed as if it were correct, you'll be amazed at what you'll
accomplish. The comment I was replying to was essentially asking, "What
would've helped you back when you were in my position?" Ten out of ten times,
I'd choose to tell myself, "Stop trying to read about how graphics engines
work. Figure out how to get triangles up on the screen, without copying
someone else."

The best I can say is that my career began from that method. And by asking a
lot of questions on IRC.

~~~
ska
Glad it worked for you, but that doesn't make it good advice. And doesn't
change the lack of uniqueness. It's usually a mistake to generalize from your
own experience, when thinking about pedagogy. I'd wager that most people would
do ok following that advice as if it were true ... But not as well as if
they'd read as well.

------
mmosta
Great article regardless of your familiarity with computer graphics or draw
pipeline.

The supporting media and presentation are as exceptional as the bespoke game
engine (RAGE)[0] used in in the GTA series.

[0]
[https://en.wikipedia.org/wiki/Rockstar_Advanced_Game_Engine](https://en.wikipedia.org/wiki/Rockstar_Advanced_Game_Engine)

------
ntaylor
GTA V's rendering engine has been fascinating to me since I bought it on the
Xbox 360, then the PS4, and now the PC. It manages to improve significantly
each time. Truly an incredible technical and artistic accomplishment.

This series of blog posts is excellent.

------
jordanthoms
GTA V's performance and graphics quality when driving around on the PS3 was
truly amazing given the hardware, neat to see how they achieved that.

------
aaronsnoswell
"Then, to simulate a real-world camera, a lens-distortion is performed on the
image by using a small pixel shader. It does not only distorts the image, it
also introduces small chromatic aberrations on the edges of the frame, by
slightly distorting more the red channel compared to the green and blue ones."

Why would the engine do this? Is it to try and give a 'cinematic' feel to the
game? Do our eyes suffer Chromatic aberration?

~~~
kgabis
They do, but it's removed in post processing :) I like how movie-like GTA V
feels and things like that help to achieve this effect.

------
LeoNatan25
Astonishing achievement. Now take a look at Batman Arkham Knight on PC and the
marvelous technical failure it is.

~~~
TrevorJ
If anything, that article gives an inkling of the infinite multitude of ways
to screw it up. It's amazing games work as well as they do.

------
dates
How did the author figure all of that information out?

~~~
lispit
From part 3:

>Links

>The tech that built an empire: how Rockstar created the world of GTA 5
featuring an interview of Aaron Garbut.
[http://www.techradar.com/news/gaming/the-tech-that-built-
an-...](http://www.techradar.com/news/gaming/the-tech-that-built-an-empire-
how-rockstar-created-the-world-of-gta-5-1181281)

>GTA V NVIDIA Performance Guide with details about the different graphics
settings. [http://www.geforce.com/whats-new/guides/grand-theft-auto-
v-p...](http://www.geforce.com/whats-new/guides/grand-theft-auto-v-pc-
graphics-and-performance-guide)

>Renderdoc which made picking into GTA V internals a breeze.
[https://github.com/baldurk/renderdoc](https://github.com/baldurk/renderdoc)

------
dkns
Not only a great article but also superbly presented. I really liked all the
screenshots showing before and after difference.

------
13thLetter
Great article. The author did a fantastic job of making the techniques
understandable and bringing them down to earth, without dumbing them down --
people who are experienced in graphics are going to learn a few tricks as well
from reading this.

------
blt
This is a great article, really amazed at both the computational power of
modern hardware and the skill displayed in getting the most out of it. Too bad
the game industry sucks to work in or I'd be a game engine programmer for
sure.

------
swampthinker
The interactive cube demonstration is remarkably well done Adrian. Love it!

------
oxide
Reading about how optimization is handled in games is extremely interesting.

It really makes me appreciate some of the more well optimized games, it sounds
like solving a very difficult puzzle.

------
kazinator
The "cube map" looks exactly like what Google StreetView does to represent
views of the environment from given geographical coordinates.

------
supercoder
And it all happens in 16ms...

~~~
sscotth
33ms (at best)... There's a max 30fps on consoles.
[https://www.youtube.com/watch?v=y_XREfxf4ds](https://www.youtube.com/watch?v=y_XREfxf4ds)

~~~
LeoNatan25
On PC it reaches 60 frames quite easily on moderate hardware, and quite beyond
as the hardware improves.

------
nitpickifying

      > ... it’s a real technical prowess.
    

That sentence could be re-worded as:

    
    
      > ... it’s a real display of technical prowess.
    

or

    
    
      > ... it’s a real technical achievement.

