OpenGL ES 2.0顶点转换算法(OpenGL ES 2.0 Vertex Transformation Algorithms)

编程入门 行业动态 更新时间:2024-10-27 03:36:00
OpenGL ES 2.0顶点转换算法(OpenGL ES 2.0 Vertex Transformation Algorithms)

我正在用OpenGL ES 2.0开发图像变形iOS应用程序。

我对设置,管线等有很好的把握,现在正在进行数学运算。

由于我对图像变形的经验是零,所以我想了解一些算法建议。

目前,我以网格类型的方式设置点的初始顶点,将图像平分为正方形。 然后,我在每个方块的中间放置一个额外的顶点。 当我绘制索引时,每个正方形都包含四个呈X形的三角形。请参见下图:

稍微玩了一下photoshop之后,我发现Adobe为他们的木偶使用了一个稍微复杂一点的算法,但是他们的标准warp却使用了更简单的算法。 你认为最适合我在这里申请/个人喜好的是什么?

其次,当我移动一个顶点时,我想对所有其他顶点应用加权变换来平滑边缘(而不是我下面只有选定顶点被变换的位置)。 我应该在这里应用什么样的算法?

I'm developing an image warping iOS app with OpenGL ES 2.0.

I have a good grasp on the setup, the pipeline, etc., and am now moving along to the math.

Since my experience with image warping is nil, I'm reaching out for some algorithm suggestions.

Currently, I'm setting the initial vertices at points in a grid type fashion, which equally divide the image into squares. Then, I place an additional vertex in the middle of each of those squares. When I draw the indices, each square contains four triangles in the shape of an X. See the image below:

After playing with photoshop a little, I noticed adobe uses a slightly more complicated algorithm for their puppet warp, but a much more simplified algorithm for their standard warp. What do you think is best for me to apply here / personal preference?

Secondly, when I move a vertex, I'd like to apply a weighted transformation to all the other vertices to smooth out the edges (instead of what I have below, where only the selected vertex is transformed). What sort of algorithm should I apply here?

最满意答案

由于顶点着色器独立处理每个顶点,所以顶点不易影响彼此的位置。 然而,因为没有太多的顶点,所以在CPU上完成工作并且动态地更新每帧的顶点属性应该没有问题。

由于您所寻找的是为了让您的表面像橡胶板一样被拉动,因此如何继续并实施橡胶板的动态模拟? 有很多关于杰夫兰德的完整3D布料模拟的优秀文章。 您的应用程序可能是对这些技术的简化。 我以前在3D中实现过这样的模拟 。 我需要一个力量吸引我生成的顶点到他们原来的网格位置。 在模拟开始之前,您可能会有一个类似的力吸引顶点到它们生成的像素。 这将使它们在单独放置时回弹到默认状态,并逐渐减少拖动到更远角顶点的影响。

As each vertex is processed independently by the vertex shader, it is not easy to have vertexes influence each other's positions. However, because there are not that many vertexes it should be fine to do the work on the CPU and dynamically update your vertex attributes per frame.

Since what you are looking for is for your surface to act like a rubber sheet as parts of it are pulled, how about going ahead and implementing a dynamic simulation of a rubber sheet? There are plenty of good articles on cloth simulation in full 3D such as Jeff Lander's. Your application could be a simplification of these techniques. I have previously implemented a simulation like this in 3D. I required a force attracting my generated vertexes to their original grid locations. You could have a similar force attracting vertexes to the pixels at which they are generated before the simulation is begun. This would make them spring back to their default state when left alone and would progressively reduce the influence of your dragging at more distant vertexes.

更多推荐

本文发布于:2023-08-03 16:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:顶点   算法   OpenGL   ES   Transformation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!