Dynamically submit color arrays and switch pipelines #1314
-
Hello everyone, when I created a StateGroup and added it to the scene, I want to change the color of the overall point cloud and use the corresponding FragShader, so can I dynamically change the drawCommand and bindGraphicsPipeline in the stateGroup? Although I find that there are similar cases vsgdynamicvertex, it seems that it is faster to call a higher color of each point and then call the dirty to resubmit the entire colorArray to the GPU. Do you have any better solutions ? QwQ |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
What do you mean by higher color? Could you mean a material property? What shaders are you using? Your own or one of the built-in shaders? The later have a material structs that are passed via vsg::DescriptorBuffer, just like we arrays you can mark the associated data as dynamic and dirty the data in the same way. |
Beta Was this translation helpful? Give feedback.
-
I have considered that when the amount of point cloud data is large, 1: using simple shaders and dynamic dirty data, the frame rate will decrease at the moment of rendering, but it will return to normal frame rate after a short period of time; 2: When using more complex shaders, passing in some control switches through uniform and using if else statements in shaders seems to waste more time. Under normal circumstances, in big data point clouds, although dynamic switching does not cause frame rate fluctuations, it seems that the frame rate will be lower than the first situation. I am not an expert, and I am not sure how much image a shader with a lot of judgment will produce when dealing with large amounts of data. |
Beta Was this translation helpful? Give feedback.
-
Looking at your shader, it looks to me like you could update the IntensityParam uniform per frame and should perform well. Having conditionals in the vertex shader might be performance bottleneck but I think modern hardware is so fast you'll be probably be limited more by memory bandwidth reading all the vertex data. What you set up the vsg::DescriptorBuffer to pass the IntensityParam uniform you should just need to set up the data's property.dataVariance to vsg::DYNAMIC_DATA, then call dirty() on the data when you update it. Have a look at the vsgExamples that set up DYNAMIC_DATA, they do it with different data, for vertex arrays, to textures to uniforms: ./examples/volume/vsgvolume/vsgvolume.cpp: data->properties.dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgcomputevertex/vsgcomputevertex.cpp: computeScale->properties.dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgdynamictexture_cs/vsgdynamictexture_cs.cpp: textureData->properties.dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: vsg::DataVariance dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: dataVariance = vsg::STATIC_DATA;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: dataVariance = vsg::DYNAMIC_DATA_TRANSFER_AFTER_RECORD;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: textureData->properties.dataVariance = dataVariance;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: textureData->properties.dataVariance = dataVariance;
./examples/state/vsgdynamictexture/vsgdynamictexture.cpp: textureData->properties.dataVariance = dataVariance;
./examples/state/vsgtexturearray/vsgtexturearray.cpp: if (update) textureData->properties.dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp: vsg::DataVariance dataVariance = vsg::DYNAMIC_DATA;
./examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp: dataVariance = vsg::STATIC_DATA;
./examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp: dataVariance = vsg::DYNAMIC_DATA_TRANSFER_AFTER_RECORD;
./examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp: vertices->properties.dataVariance = dataVariance;
./examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp: if (dataVariance == vsg::STATIC_DATA)
./examples/state/vsgclip/vsgclip.cpp: eyeClipSettings->properties.dataVariance = vsg::DYNAMIC_DATA;
./examples/raytracing/vsgraytracing/vsgraytracing.cpp: raytracingUniform->properties.dataVariance = vsg::DataVariance::DYNAMIC_DATA;
./examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp: texgenMatrices->properties.dataVariance = vsg::DYNAMIC_DATA; |
Beta Was this translation helpful? Give feedback.
Looking at your shader, it looks to me like you could update the IntensityParam uniform per frame and should perform well. Having conditionals in the vertex shader might be performance bottleneck but I think modern hardware is so fast you'll be probably be limited more by memory bandwidth reading all the vertex data.
What you set up the vsg::DescriptorBuffer to pass the IntensityParam uniform you should just need to set up the data's property.dataVariance to vsg::DYNAMIC_DATA, then call dirty() on the data when you update it.
Have a look at the vsgExamples that set up DYNAMIC_DATA, they do it with different data, for vertex arrays, to textures to uniforms: