Created
September 16, 2013 15:55
-
-
Save ttvd/6582569 to your computer and use it in GitHub Desktop.
Killzone 2 decision tree rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I hope I'm going to be able to describe what we do there - it's really no magic | |
involved - we just wanted something simple. | |
The decision tree is quite simple structure - leaf nodes are individual | |
drawparts (drawpart is a structure that contains vertex array, index array, | |
shader, matrices, constants... - the minimum data to render something without | |
any higher logic required) and non-leaf nodes pretty much contain | |
rules/conditions determining what child node to pick - since we don't want | |
to have any virtual calls there, we only have predefined set of conditions | |
such as LOD node (based on distance from camera), "switch" node | |
(explicitly pick certain child) and couple more (just imagine a giant | |
switch statement with all possible node types). The whole tree is one | |
linear block of memory so we can easily DMA it onto SPU, start in the | |
root and go through the decision nodes and output list of the relevant | |
leaf drawparts. We then merge all drawparts for the frame and just render | |
the list. | |
The reason why the tree contains only couple of different node types | |
is because all higher level game logic is done at different point - | |
therefore the representation layer of the game can stay simple. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment