How to add matrix and vector to uniform "PushConstants"? #1454
-
In the customize shader Screen, I need append more matrix and vector to a uniform , and change these value for every frame rendering. Like emulation time as float, current frame index for bone animation. I really need a complete code sample for this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There isn't yet an example illustrating using of push constants. The vsg::PushConstant wraps the vkCmdPushConstants() and provides the mechanism for pass the data at the appropriate offset. You also need to set up the pipeline layout for it as well. However, push constants might not be the most appropriate tool. Push constants are best for high frequency changes in state. Simulation time and frame count is low frequency state that will be updated once per frame that is better suited to a uniform. The vsg::ViewDependentState has the type of granularity of that would be appropriate. Perhaps it could even be extended to include simulation time and frame count as an option as I can see this being something other users would fine useful too. Currently ViewDependentState provides the lighting, shadow map and viewport information. |
Beta Was this translation helpful? Give feedback.
-
When you set up the flogValue you need to set the Data::Properities::dataVariance to vsg::DYNAMIC, something like:
Then when the viewer->compile() is called the dynamic data will be picked up and automatically assigned to the vsg::TransferTask so that it's checked each frame to see if it's dirty, and if it is have the new value copied to the associated buffer on the GPU. The vsgdynamicvertex and vsgdynamictexture examples illustrates how dynamic data is managed in the VSG. |
Beta Was this translation helpful? Give feedback.
There isn't yet an example illustrating using of push constants. The vsg::PushConstant wraps the vkCmdPushConstants() and provides the mechanism for pass the data at the appropriate offset. You also need to set up the pipeline layout for it as well.
However, push constants might not be the most appropriate tool. Push constants are best for high frequency changes in state. Simulation time and frame count is low frequency state that will be updated once per frame that is better suited to a uniform.
The vsg::ViewDependentState has the type of granularity of that would be appropriate. Perhaps it could even be extended to include simulation time and frame count as an option as I can see this b…