diff options
Diffstat (limited to 'gfx/include/gfx/scene/README.md')
| -rw-r--r-- | gfx/include/gfx/scene/README.md | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/gfx/include/gfx/scene/README.md b/gfx/include/gfx/scene/README.md index 1910abe..c8cdadb 100644 --- a/gfx/include/gfx/scene/README.md +++ b/gfx/include/gfx/scene/README.md | |||
| @@ -10,7 +10,7 @@ A scene graph implementation that includes: | |||
| 10 | - Object | 10 | - Object |
| 11 | - Scene | 11 | - Scene |
| 12 | 12 | ||
| 13 | ## Hierarchy and parenting | 13 | ## Hierarchy and Parenting |
| 14 | 14 | ||
| 15 | Scene graphs typically expose functions on nodes to add/remove objects, cameras, | 15 | Scene graphs typically expose functions on nodes to add/remove objects, cameras, |
| 16 | lights, etc. This implementation forces the hierarchy to be a strict tree and | 16 | lights, etc. This implementation forces the hierarchy to be a strict tree and |
| @@ -25,3 +25,51 @@ glTF 2.0 spec [enforces this](https://github.com/KhronosGroup/glTF/blob/master/s | |||
| 25 | > acyclic graph (DAG) or scene graph, but a disjoint union of strict trees. That | 25 | > acyclic graph (DAG) or scene graph, but a disjoint union of strict trees. That |
| 26 | > is, no node may be a direct descendant of more than one node. This restriction | 26 | > is, no node may be a direct descendant of more than one node. This restriction |
| 27 | > is meant to simplify implementation and facilitate conformance.* | 27 | > is meant to simplify implementation and facilitate conformance.* |
| 28 | |||
| 29 | ## Instancing | ||
| 30 | |||
| 31 | Two use cases for instancing seem to be: | ||
| 32 | |||
| 33 | 1. Creating N identical clones, but each with a unique transform. (Ex: N | ||
| 34 | animated characters animated in unison but located in different locations.) | ||
| 35 | 2. Creating N copies of a sub-tree, each now being their own unique tree. (Ex: | ||
| 36 | The same N animated characters, but each of them now being animated separately.) | ||
| 37 | |||
| 38 | Some scene graphs | ||
| 39 | ([Panda3D](https://docs.panda3d.org/1.10/python/programming/scene-graph/instancing)) | ||
| 40 | allow two or more nodes to point to the same child, or, in other words, a node | ||
| 41 | to have multiple parents. This turns the scene graph into a DAG and adds a | ||
| 42 | number of complications for us: | ||
| 43 | |||
| 44 | 1. Shared ownership of children. We would now need some sort of ref counting or | ||
| 45 | deferred GC to delete nodes and their subtrees. | ||
| 46 | 2. Nodes no longer have a unique parent. | ||
| 47 | 3. Given a node, we can no longer determine its location (which parent link do | ||
| 48 | you follow?), or any attribute that is derived from its parent(s). | ||
| 49 | |||
| 50 | In our case, we stick to strict tree hierarchies. | ||
| 51 | |||
| 52 | Use case (1), N identical clones with unique transforms, is not a problem for | ||
| 53 | us. This is because the bulk of the data -- geometry buffers, etc. -- is stored | ||
| 54 | in the render backend anyway. So creating a full copy of the node does not | ||
| 55 | present a significant overhead since we need a unique transform for each of the | ||
| 56 | clones anyway. | ||
| 57 | |||
| 58 | Use case (2) does present a bit more overhead and we currently do not handle it. | ||
| 59 | This could be handled in the future by special-casing a node such as | ||
| 60 | `InstanceNode` that has one child subtree and N transforms (or other | ||
| 61 | attributes), one for each unique instance of that child subtree. | ||
| 62 | |||
| 63 | Therefore, to visit the use cases again: | ||
| 64 | |||
| 65 | 1. N character clones animated in unison in different locations -> future | ||
| 66 | `InstanceNode`. | ||
| 67 | 2. N unique character copies animated on their own -> copy the character subtree | ||
| 68 | (N unique skeletons; shared mesh data and textures stored in the render | ||
| 69 | backend.) | ||
| 70 | |||
| 71 | ## Reading | ||
| 72 | |||
| 73 | [Panda3D Scene Graph](https://docs.panda3d.org/1.10/python/programming/scene-graph/index) | ||
| 74 | |||
| 75 | [Pixar's USD](https://graphics.pixar.com/usd/release/intro.html) | ||
