Instanced rendering of imported with vsgXchange models #1154
-
Hello! I have a task to render high amount (more than 10 000) of tree models (they are imported via vsgXchange). If i set models in graph as separate Nodes, as expected, everything is dying. Is there implemented way to render imported models instanced with one draw call? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
When you say "everything is dying" it alludes to issues but doesn't actual say what they are. You also don't give us any content for your tree model. How complex is it? How was it created? Are you uses vsg::SharedObjects as example like vsgviewer do? Vulkan instancing works at the vkDraw/vgDrawInstance level rather than at the scene graph level. At the scene graph level you can load a model ones then put it under a vsg::MatrixTransform to place each instance at isn't own unique position. There is instancing support integrated in the all the built in ShaderSet's but it needs to be driven at the vsg::Draw/DrawInstance/VertexIndexDraw/Geometry level. The vsgbuilder example illustrates how to set up instancing for shapes created by vsg::Builder so might be a bit of interest. The vsg::Builder implementation itself may also be of interest. What type of instancing you actually need or what is applicable in your case I can't say as you haven't given any context. I also don't know what level it pitch answers as I don't know what you knowledge level is of graphics/Vulkan etc. |
Beta Was this translation helpful? Give feedback.
-
The [standard.vert](https://github.com/vsg-dev/vsgExamples/blob/master/data/shaders/standard.vert ,that is used in the flat shaded, phong and pbr (that vsgXchange::assimp typically uses) ShaderSet's, have support for instancing, but as I explained that doesn't work for whole subgraphs. The VSG_BILLBOARD and VSG_INSTANCE_POSITION code paths in the standard.vert are what map per instance position data to positioning of meshes. So you need to pass in the position array to the vertex array setup. This setup is much easier why you create your own geometry subgraphs, reaching into arbitrarily complex subgraphs will be less easy - if you want to keep pursuing what you are doing this is what you'll have to figure out how to do yourself. As a general comment 10,000 simple models shouldn't make a system paricular slow. Are you buidng and testing everything in debug? Running with CPU drivers? What hardware? Also a general comment convert your model to a .vsgt and just study the objects that are in the subgraph. |
Beta Was this translation helpful? Give feedback.
The [standard.vert](https://github.com/vsg-dev/vsgExamples/blob/master/data/shaders/standard.vert ,that is used in the flat shaded, phong and pbr (that vsgXchange::assimp typically uses) ShaderSet's, have support for instancing, but as I explained that doesn't work for whole subgraphs.
The VSG_BILLBOARD and VSG_INSTANCE_POSITION code paths in the standard.vert are what map per instance position data to positioning of meshes. So you need to pass in the position array to the vertex array setup.
This setup is much easier why you create your own geometry subgraphs, reaching into arbitrarily complex subgraphs will be less easy - if you want to keep pursuing what you are doing this is what you'…