How to update projection and view matrixes by Uniform buffer? #1149
-
The camera holds the projection and view matrixes and I found it was updated every frame by push constant. How should I set to update the camera matrixes by using a uniform buffer? Because I want to change some properties between draw calls, which is implemented by pushing constant. So I want to update camera matrixes by using a uniform buffer |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The VSG does not pass the Camera View matrix to the GPU, it passes a modelview matrix that is accumulated during the RecordTraversal. This is done to preserve precision in double ssas long as possible before the final matrix has cast down to float and passed to the GPU. This technique is how the VSG is able to seamlessly cope with whole earth databases without the precision issues. For performance reasons you want to at least pass the modelview matrix by push constants as it can vary so often between leaves of the scene graph. Projection matrix is currently passed by push constant alongside the modelview matrix, but this is something I've considered changing this is a projection matrix to a uniform as this only varies once per view per frame, and possibly a view offset for multiview/stereo applications. Putting the projection matrix into a uniform would free up push constant space, but still the modelview matrix really needs to be passed as push constant. All the current built-in ShaderSets assume projection and modelview matrices are push constants so that is another issue that would need to be changed. If you provide all your own shaders then potentially you could pass your own uniforms but the vsg::State is still geared up to pass the project and modelview matrices as push constants so that class would need adapting to do this. A simpler option would be to just allocated your push constants above the current first 128bytes used by vsg::State to push the project and modelview matrices. Also consider use per instance array data or BindDescriptorSet to bind uniforms. One has to asked, just what you are trying to achieve, rather than how you are going about it. How many draw commands are we talking about? How many changes of state between them do you need to make? How much data do you need to change? |
Beta Was this translation helpful? Give feedback.
-
In the case of line width this is not something you can control with push constants/uniforms you'll need to do it via the graphics pipeline configuration or enable dynamic state and override the line width using vsg::SetLineWidht/vkSetLineWidth. https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/commands/SetLineWidth.h The vsgdynamicstate example shows you this is done: |
Beta Was this translation helpful? Give feedback.
The VSG does not pass the Camera View matrix to the GPU, it passes a modelview matrix that is accumulated during the RecordTraversal. This is done to preserve precision in double ssas long as possible before the final matrix has cast down to float and passed to the GPU. This technique is how the VSG is able to seamlessly cope with whole earth databases without the precision issues.
For performance reasons you want to at least pass the modelview matrix by push constants as it can vary so often between leaves of the scene graph. Projection matrix is currently passed by push constant alongside the modelview matrix, but this is something I've considered changing this is a projection matrix to…