using model matrix or view matrix in the shader #693
Replies: 3 comments 4 replies
-
If you can avoid using view and model matrices in shaders you can avoid precision problems that occur when the view matrix values become large. The VulkanSceneGraph is designed to handle really large to tiny worlds where ability handle precision issues are critical so use modelview matrix are the default. Sadly lots of example shaders out there use separate model and view matrices are introduce this precision problem, then when developers trying to scale there worlds from toy examples into large real world scales they are hit by an intractable precision problems. While it's technically possible to pass separate model and view matrices directly yourself, I would strongly recommend thinking about how to refactor shaders so they can work with modelview matrices that the VSG provides out of the box. We can help make suggestions, but wihtout knowing what might be in your shaders and what type of scene you are trying to render it's too open ended attempt. |
Beta Was this translation helpful? Give feedback.
-
I'm moving this "Issue" to the Discussion pages where it belongs as it's not a bug or build problem with the VSG itself. |
Beta Was this translation helpful? Give feedback.
-
I was going to reply with essentially the same thing that @robertosfield said. If you really need these matrices, then the most productive way to proceed would be to modify vsg::ViewDependentState to (optionally) pass the view matrix and view matrix inverse in its uniform buffer. Once you have the those, you can extract the model matrix from the ModelView matrix. Robert can comment on whether or not he would accept such a patch. |
Beta Was this translation helpful? Give feedback.
-
I figured out that vsg use push constant to update projection matrix and modelview matrix. how can I just use model or view matrix in the shader.
Beta Was this translation helpful? Give feedback.
All reactions