PositionAttitudeTransform from OpenSceneGraph to VulkanSceneGraph #1289
Replies: 2 comments 5 replies
-
A PositionAttitudeTransform node is one I've hand in but hadn't got around to implementing it yet, so if you are able to open source I'd welcome a PR for it's addition. The VulkanSceneGraph doesn't have bounding volumes assigned to all scene graph nodes like the OpenSceneGraph does, and there isn't a mechanism for propagating changes in bounding volumes either. This means there no Node dirtyBound() mechanism. The Data::dirty() mechanism is for vertex arrays, uniforms and texture data and is used to inform the TransferTask when to copy changes to the associated GPU memory. This is quite different from changes to the internal nodes of a scene graph which are purely CPU based. The fact that the VSG doesn't a have a general bounding volume assigned to all all scene graph nodes is decision I made to remove the performance overhead of storing a bounding sphere in all nodes, and doing checks for culling enabled and doing the culling itself on all nodes. This decision along with no node callbacks and masks is how the VSG keeps the vsg::Node size down to just 24 bytes vs the osg::Node 208 bytes. This really helps reduced the memory bandwidth load and reduce cache misses when traversing the scene graph, and avoiding doing lots of node mask and culling checks on every node avoids tripping branch prediction and improves pre-fetch on the CPU so the VSG ends up being over 10x faster at traversals. Culling and masks are still important for performance and usability of the scene graph, so there are fully supported, but just moved to dedicated culling nodes - vsg::CullGroup/CullNode/LOD/PagedLOD and dedicate mask handling with vsg::Switch. This means users need to place these nodes where they need them/judge them to be important for performance. If you have a transform that is dynamically updated in the scene and you want to do culling on that subgraph it's generally best to place the culling node below the dynamically updated transform, this way it's bounds don't need to be updated dynamically as well. If you have something like an animated character where there are lots of moving parts one would put a cull node with a static bounding volume for it which is big enough to encompass the local range of movement, so no matter the positions the culling will still work correctly. These approach of using conservative bounding volumes might be a potential performance hit if the subgraph was really expensive to render, but for most scene graph applications and modern hardware the CPU and GPU throughput for many objects is much lower - especially as the CPU and GPU overhead of the VSG and Vulkan are much lower than OSG and OpenGL the gain from avoiding lowering CPU throughput is better than the gain you might achieve with slightly more culling. |
Beta Was this translation helpful? Give feedback.
-
One approach I've considered as a replacement for PositionAttitudeTransform is a CompositeTransform subclass from Transform where it has a list of TransformComponent objects, and each TransformComponent has a virtual transform method that can modify the modelview matrix. One then would have TranslantionComponent, RotationComponent and ScaleComponent subclasses that can be put in any order to achieve the end result the user wants. As it depends upon virtual methods and multiple objects it'll have a high CPU overhead than a hardwired PositionAttitudeTransform but it'd be much more flexible, with the same level of flexibility of having a hierarchy of Transform nodes but with lower CPU overhead. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm migrating some projects from OpenSceneGraph to VulkanSceneGraph and realized that there isn't a PositionAttitudeTransform class in VSG, which I need. So, I decided to implement the class myself. However, while refactoring the header and source files from the original OSG class to VSG, I noticed that the dirtyBound() function from osg::Node is not available in vsg::Node. I found a Data::dirty() function in the documentation, but it doesn't seem to have the same effect. Could someone help me? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions