简体   繁体   English

vulkan中的转换函数

[英]Transformation functions in vulkan

Can anyone help me find resources to study about how to implement transformation functions (Translation, rotation & scaling) using Vulkan API on windows platform? 谁能帮助我找到资源,以研究如何在Windows平台上使用Vulkan API实现转换功能(平移,旋转和缩放)? There are very limited sources on Vulkan as far as I know and I couldn't find a single material about transformations in Vulkan. 据我所知,关于Vulkan的资料非常有限,我找不到有关Vulkan转换的单一材料。

If You are looking for a source code, Vulkan Cookbook has code samples implementing each of these transformations ( translation , rotation and scaling ). 如果您正在寻找源代码, Vulkan Cookbook的代码示例实现了这些转换( 平移旋转缩放 )中的每一个。

If You are looking for an explanation why they are implemented in such a way, You can look for any resources describing these transformations. 如果您正在寻找为什么以这种方式实现它们的解释,则可以寻找描述这些转换的任何资源。 Translation, rotation and scaling behave exactly the same, no matter what API You are using. 无论您使用什么API,平移,旋转和缩放的行为都完全相同。 This is pure linear algebra. 这是纯线性代数。 There are differences in projection matrices due to different coordinate systems being used (Vulkan has depth in a [0; 1] range while OpenGL in a [-1; 1] range; and framebuffer space is inverted along Y axis). 由于使用不同的坐标系,投影矩阵有所不同(Vulkan的深度在[0; 1]范围内,而OpenGL在[-1; 1]范围内;并且帧缓冲区空间沿Y轴反转)。 But the same methodologies apply when You are constructing them by Yourself, You just need to take into account these different coord systems. 但是,当您自己构建它们时,将应用相同的方法,您只需要考虑这些不同的坐标系统即可。

The best resource I have encountered describing why matrices are created in such a way, was Frank D. Luna's Introduction to 3D Game Programming with DirectX . 我所遇到的描述为什么创建矩阵的最佳资源是Frank D. Luna的DirectX 3D游戏编程简介

If you're looking for something like the equivalent of glTranslatef , glScalef , and glRotatef , you're out of luck. 如果您正在寻找类似glTranslatefglScalefglRotatef ,那您glScalef走运了。 Nothing like that exists in Vulkan (or in modern OpenGL, for that matter). Vulkan(或现代OpenGL)不存在这种情况。 With modern rendering API's you manage transforms (view, model, projection) on the CPU side using your own preferred library (I use and recommend GLM ). 使用现代渲染API,您可以使用自己喜欢的库(我使用并推荐使用GLM )在CPU端管理变换(视图,模型,投影)。 Transforms are passed to the shaders using uniform blocks, typically as mat4 values where they can then be used to transform input vertices. 变换使用统一块(通常作为mat4值)传递到着色器,然后可将其用于变换输入顶点。

If you are asking us how to implement these by yourself, you have to study some linear algebra to do this. 如果您问我们如何自己实现这些,则必须学习一些线性代数才能做到这一点。 Previous answers answered this. 先前的答案回答了这个问题。

If not, then I suggest using GLM . 如果没有,那么我建议使用GLM It is a library originally written for OpenGL, so you have to be careful while using it. 它是最初为OpenGL编写的库,因此在使用它时必须小心。 Axes are flipped, keep that in mind. 轴被翻转,请记住这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM